diff --git a/src/app/credExplorer/App.js b/src/app/credExplorer/App.js index e88b7be..6b475c2 100644 --- a/src/app/credExplorer/App.js +++ b/src/app/credExplorer/App.js @@ -13,7 +13,7 @@ type Props = {}; type State = { repoOwner: string, repoName: string, - graph: ?Graph, + graph: ?Graph, pagerankResult: ?PagerankResult, }; diff --git a/src/app/credExplorer/basicPagerank.js b/src/app/credExplorer/basicPagerank.js index 55dbc3b..ddeb60f 100644 --- a/src/app/credExplorer/basicPagerank.js +++ b/src/app/credExplorer/basicPagerank.js @@ -29,7 +29,7 @@ type OrderedSparseMarkovChain = {| +chain: SparseMarkovChain, |}; -export default function basicPagerank(graph: Graph): PagerankResult { +export default function basicPagerank(graph: Graph): PagerankResult { const {nodeOrder, chain} = graphToOrderedSparseMarkovChain(graph); const pi = findStationaryDistribution(chain, {verbose: true}); return distributionToPagerankResult(nodeOrder, pi); @@ -41,9 +41,7 @@ function edgeWeight( return {toWeight: 1, froWeight: 1}; } -function graphToAddressMapMarkovChain( - graph: Graph -): AddressMapMarkovChain { +function graphToAddressMapMarkovChain(graph: Graph): AddressMapMarkovChain { const result = new AddressMap(); const unnormalizedTotalOutWeights = new AddressMap(); @@ -109,7 +107,7 @@ function addressMapMarkovChainToOrderedSparseMarkovChain( } export function graphToOrderedSparseMarkovChain( - graph: Graph + graph: Graph ): OrderedSparseMarkovChain { return addressMapMarkovChainToOrderedSparseMarkovChain( graphToAddressMapMarkovChain(graph) diff --git a/src/app/credExplorer/pagerankTable.js b/src/app/credExplorer/pagerankTable.js index 48fe2ee..ba0344a 100644 --- a/src/app/credExplorer/pagerankTable.js +++ b/src/app/credExplorer/pagerankTable.js @@ -15,7 +15,7 @@ import type {PagerankResult} from "./basicPagerank"; type Props = { pagerankResult: ?PagerankResult, - graph: ?Graph, + graph: ?Graph, }; type State = { @@ -65,7 +65,7 @@ export class PagerankTable extends React.Component { if (this.props.graph == null || this.props.pagerankResult == null) { throw new Error("Impossible."); } - const graph: Graph = this.props.graph; + const graph: Graph = this.props.graph; const typesByPlugin: {[pluginName: string]: Set} = {}; graph.nodes().forEach((node) => { if (!typesByPlugin[node.address.pluginName]) { @@ -154,7 +154,7 @@ export class PagerankTable extends React.Component { type RTState = {expanded: boolean}; type RTProps = {| +address: Address, - +graph: Graph, + +graph: Graph, +pagerankResult: PagerankResult, +depth: number, |}; diff --git a/src/cli/commands/pluginGraph.js b/src/cli/commands/pluginGraph.js index 16a6339..7f35782 100644 --- a/src/cli/commands/pluginGraph.js +++ b/src/cli/commands/pluginGraph.js @@ -87,7 +87,7 @@ function pluginGraph( } } -function display(promise: Promise>) { +function display(promise: Promise) { promise.then((graph) => { console.log(stringify(graph, {space: 4})); }); diff --git a/src/core/graph.js b/src/core/graph.js index 12f4ca2..3fc1c38 100644 --- a/src/core/graph.js +++ b/src/core/graph.js @@ -21,33 +21,33 @@ export type Edge<+T> = {| +payload: T, |}; -type IndexedEdge<+T> = {| +type IndexedEdge = {| +address: Address, +srcIndex: Integer, +dstIndex: Integer, - +payload: T, + +payload: any, |}; const COMPAT_TYPE = "sourcecred/sourcecred/Graph"; const COMPAT_VERSION = "0.2.0"; -type NodesSortedByStringifiedAddress = {| +type NodesSortedByStringifiedAddress = {| +address: Address, - +payload?: NP, + +payload?: any, |}[]; -export type GraphJSON = {| - +nodes: NodesSortedByStringifiedAddress, - +edges: AddressMapJSON>, +export type GraphJSON = {| + +nodes: NodesSortedByStringifiedAddress, + +edges: AddressMapJSON, |}; -type MaybeNode<+NP> = {|+address: Address, +node: Node | void|}; +type MaybeNode = {|+address: Address, +node: Node | void|}; -export class Graph { +export class Graph { // Invariant: sizes of `_nodeIndices`, `_nodes`, `_outEdges`, and // `_inEdges` are all equal. _nodeIndices: AddressMap<{|+address: Address, +index: Integer|}>; - _nodes: MaybeNode[]; - _edges: AddressMap>; + _nodes: MaybeNode[]; + _edges: AddressMap; // If `idx` is the index of a node `v`, then `_outEdges[idx]` is the // list of `e.address` for all edges `e` whose source is `v`. @@ -63,11 +63,11 @@ export class Graph { this._inEdges = []; } - copy(): Graph<$Supertype, $Supertype> { + copy(): Graph { return Graph.mergeConservative(new Graph(), this); } - equals(that: Graph): boolean { + equals(that: Graph): boolean { const theseNodes = this.nodes(); const thoseNodes = that.nodes(); if (theseNodes.length !== thoseNodes.length) { @@ -93,13 +93,13 @@ export class Graph { return true; } - toJSON(): Compatible> { + toJSON(): Compatible { const partialNodes: {| key: string, oldIndex: Integer, data: {| +address: Address, - +payload?: NP, + +payload?: any, |}, |}[] = this._nodes .map((maybeNode, oldIndex) => { @@ -162,8 +162,8 @@ export class Graph { ); } - static fromJSON(json: Compatible>): Graph { - const compatJson: GraphJSON = fromCompat( + static fromJSON(json: Compatible): Graph { + const compatJson: GraphJSON = fromCompat( { type: COMPAT_TYPE, version: COMPAT_VERSION, @@ -173,7 +173,7 @@ export class Graph { const result = new Graph(); compatJson.nodes.forEach((partialNode) => { if ("payload" in partialNode) { - const node: Node = (partialNode: any); + const node: Node = (partialNode: any); result.addNode(node); } else { result._addNodeAddress(partialNode.address); @@ -201,7 +201,7 @@ export class Graph { } } - addNode(node: Node): this { + addNode(node: Node): this { if (node == null) { throw new Error(`node is ${String(node)}`); } @@ -230,7 +230,7 @@ export class Graph { return this; } - addEdge(edge: Edge): this { + addEdge(edge: Edge): this { if (edge == null) { throw new Error(`edge is ${String(edge)}`); } @@ -245,7 +245,7 @@ export class Graph { return this._addIndexedEdge(indexedEdge); } - _addIndexedEdge(indexedEdge: IndexedEdge): this { + _addIndexedEdge(indexedEdge: IndexedEdge): this { const existingIndexedEdge = this._edges.get(indexedEdge.address); if (existingIndexedEdge !== undefined) { if (deepEqual(existingIndexedEdge, indexedEdge)) { @@ -283,18 +283,18 @@ export class Graph { return this; } - node(address: Address): Node { + node(address: Address): Node { const indexDatum = this._nodeIndices.get(address); if (indexDatum == null) { // We've never heard of this node. return (undefined: any); } else { - const node: Node | void = this._nodes[indexDatum.index].node; - return ((node: any): Node); + const node: Node | void = this._nodes[indexDatum.index].node; + return ((node: any): Node); } } - edge(address: Address): Edge { + edge(address: Address): Edge { const indexedEdge = this._edges.get(address); if (!indexedEdge) { // Lie. @@ -327,7 +327,7 @@ export class Graph { +edgeType?: string, +direction?: "IN" | "OUT" | "ANY", |} - ): {|+edge: Edge, +neighbor: Address|}[] { + ): {|+edge: Edge, +neighbor: Address|}[] { if (nodeAddress == null) { throw new Error(`address is ${String(nodeAddress)}`); } @@ -338,7 +338,7 @@ export class Graph { } const nodeIndex = indexDatum.index; - let result: {|+edge: Edge, +neighbor: Address|}[] = []; + let result: {|+edge: Edge, +neighbor: Address|}[] = []; const direction = (options != null && options.direction) || "ANY"; if (direction === "ANY" || direction === "IN") { @@ -380,7 +380,7 @@ export class Graph { * * If filter is provided, it will return only nodes with the requested type. */ - nodes(filter?: {type?: string}): Node[] { + nodes(filter?: {type?: string}): Node[] { /*:: declare function nonNulls(x: (T | void)[]): T[]; */ let nodes = this._nodes.map((x) => x.node).filter((x) => Boolean(x)); /*:: nodes = nonNulls(nodes); */ @@ -396,7 +396,7 @@ export class Graph { * * If filter is provided, it will return only edges with the requested type. */ - edges(filter?: {type?: string}): Edge[] { + edges(filter?: {type?: string}): Edge[] { let edges = this._edges.getAll().map((indexedEdge) => ({ address: indexedEdge.address, src: this._nodes[indexedEdge.srcIndex].address, @@ -418,13 +418,13 @@ export class Graph { * * The existing graph objects are not modified. */ - static merge( - g1: Graph, - g2: Graph, - nodeResolver: (Node, Node) => Node, - edgeResolver: (Edge, Edge) => Edge - ): Graph { - const result: Graph = new Graph(); + static merge( + g1: Graph, + g2: Graph, + nodeResolver: (Node, Node) => Node, + edgeResolver: (Edge, Edge) => Edge + ): Graph { + const result: Graph = new Graph(); g1.nodes().forEach((node) => { if (g2.node(node.address) !== undefined) { const resolved = nodeResolver(node, g2.node(node.address)); @@ -460,10 +460,7 @@ export class Graph { * for edges). If this assumption does not hold, this function will * raise an error. */ - static mergeConservative( - g1: Graph, - g2: Graph - ): Graph { + static mergeConservative(g1: Graph, g2: Graph): Graph { function conservativeResolver( kinds: string /* used for an error message on mismatch */, a: T, @@ -477,7 +474,7 @@ export class Graph { ); } } - const result: Graph = Graph.merge( + const result: Graph = Graph.merge( g1, g2, (u, v) => conservativeResolver("nodes", u, v), @@ -493,9 +490,7 @@ export class Graph { * * but uses a mutable accumulator for improved performance. */ - static mergeManyConservative( - graphs: $ReadOnlyArray, $Subtype>> - ): Graph { + static mergeManyConservative(graphs: $ReadOnlyArray): Graph { const result = new Graph(); graphs.forEach((graph) => { graph.nodes().forEach((node) => { diff --git a/src/core/graph.test.js b/src/core/graph.test.js index 9f836e0..6e1267f 100644 --- a/src/core/graph.test.js +++ b/src/core/graph.test.js @@ -388,7 +388,7 @@ describe("graph", () => { describe("neighborhood detection", () => { describe("type filtering", () => { class ExampleGraph { - graph: Graph<{}, {}>; + graph: Graph; root: Address; idIncrement: number; inEdges: {[string]: Edge<{}>}; @@ -891,9 +891,7 @@ describe("graph", () => { * node `u`, create a graph with just that node, its neighbors, * and its incident edges (in both directions). */ - function neighborhoodDecomposition( - originalGraph: Graph - ): Graph[] { + function neighborhoodDecomposition(originalGraph: Graph): Graph[] { return originalGraph.nodes().map((node) => { const miniGraph = new Graph(); miniGraph.addNode(node); @@ -925,9 +923,7 @@ describe("graph", () => { * create a graph with just that edge and its two endpoints, and * for each isolated node createa graph with just that node. */ - function edgeDecomposition( - originalGraph: Graph - ): Graph[] { + function edgeDecomposition(originalGraph: Graph): Graph[] { const edgeGraphs = originalGraph.edges().map((edge) => { const miniGraph = new Graph(); miniGraph.addNode(originalGraph.node(edge.src)); @@ -1001,17 +997,16 @@ describe("graph", () => { payload: null, }), }; - const g1: Graph = new Graph() + const g1: Graph = new Graph() .addNode(data.a()) .addNode(data.b()) .addEdge(data.u()); - const g2: Graph = new Graph() + const g2: Graph = new Graph() .addNode(data.c()) .addNode(data.d()) .addEdge(data.v()); - type ResultGraph = Graph; - const result: ResultGraph = Graph.mergeConservative(g1, g2); - const expected: ResultGraph = new Graph() + const result = Graph.mergeConservative(g1, g2); + const expected = new Graph() .addNode(data.a()) .addNode(data.b()) .addEdge(data.u()) @@ -1022,7 +1017,7 @@ describe("graph", () => { }); it("conservatively rejects a graph with conflicting nodes", () => { - const makeGraph: (nodePayload: string) => Graph<*, *> = (nodePayload) => + const makeGraph: (nodePayload: string) => Graph = (nodePayload) => new Graph().addNode({ address: demoData.makeAddress("conflicting-node", "EXPERIMENT"), payload: nodePayload, @@ -1037,7 +1032,7 @@ describe("graph", () => { it("conservatively rejects a graph with conflicting edges", () => { const srcAddress = demoData.makeAddress("src", "EXPERIMENT"); const dstAddress = demoData.makeAddress("dst", "EXPERIMENT"); - const makeGraph: (edgePayload: string) => Graph<*, *> = (edgePayload) => + const makeGraph: (edgePayload: string) => Graph = (edgePayload) => new Graph() .addNode({address: srcAddress, payload: {}}) .addNode({address: dstAddress, payload: {}}) @@ -1149,7 +1144,6 @@ describe("graph", () => { address: demoData.makeAddress("hello", "EXPERIMENT"), payload: 17, }; - // This will be a Graph. new Graph().addNode(stringNode).addNode(numberNode); }); }); @@ -1176,7 +1170,6 @@ describe("graph", () => { dst: dst.address, payload: 18, }; - // This will be a Graph<{}, string | number>. new Graph() .addNode(src) .addNode(dst) @@ -1205,12 +1198,6 @@ describe("graph", () => { expect(g1.equals(g2)).toBe(true); expect(g1.equals(demoData.advancedMealGraph())).toBe(true); }); - - function _unused_itAllowsUpcastingPayloadTypes( - g: Graph<{x: string, y: number}, boolean> - ): Graph<{x: string}, ?boolean> { - return g.copy(); - } }); }); }); diff --git a/src/core/porcelain.js b/src/core/porcelain.js index fdd79e9..47ab118 100644 --- a/src/core/porcelain.js +++ b/src/core/porcelain.js @@ -4,10 +4,10 @@ import type {Address} from "./address"; import type {Edge, Graph, Node} from "./graph"; export class NodeReference<+T> { - _graph: Graph; + _graph: Graph; _address: Address; - constructor(g: Graph, a: Address) { + constructor(g: Graph, a: Address) { this._graph = g; this._address = a; } @@ -25,7 +25,7 @@ export class NodeReference<+T> { })); } - graph(): Graph { + graph(): Graph { return this._graph; } diff --git a/src/plugins/artifact/artifactPlugin.js b/src/plugins/artifact/artifactPlugin.js index 1700bc8..2893fad 100644 --- a/src/plugins/artifact/artifactPlugin.js +++ b/src/plugins/artifact/artifactPlugin.js @@ -23,7 +23,7 @@ export type EdgePayload = IncludesEdgePayload; const NON_SLUG_CHARACTER: RegExp = /[^a-z]/g; export function artifactAddress( - graph: Graph, + graph: Graph, repoOwner: string, repoName: string, artifactName: string diff --git a/src/plugins/artifact/editor/App.js b/src/plugins/artifact/editor/App.js index 53df539..f98b83b 100644 --- a/src/plugins/artifact/editor/App.js +++ b/src/plugins/artifact/editor/App.js @@ -6,14 +6,7 @@ import {StyleSheet, css} from "aphrodite/no-important"; import "./pluginAdapter"; import type {Graph, Node} from "../../../core/graph"; -import type { - NodePayload as GithubNodePayload, - EdgePayload as GithubEdgePayload, -} from "../../github/types"; -import type { - NodePayload as ArtifactNodePayload, - EdgePayload as ArtifactEdgePayload, -} from "../artifactPlugin"; +import type {NodePayload as ArtifactNodePayload} from "../artifactPlugin"; import type {Settings} from "./SettingsConfig"; import {ArtifactGraphEditor} from "./ArtifactGraphEditor"; import {ContributionList} from "./ContributionList"; @@ -24,8 +17,8 @@ import standardAdapterSet from "./standardAdapterSet"; type Props = {}; type State = { artifacts: Node[], - githubGraph: ?Graph, - artifactGraph: ?Graph, + githubGraph: ?Graph, + artifactGraph: ?Graph, settings: Settings, }; diff --git a/src/plugins/artifact/editor/ArtifactGraphEditor.js b/src/plugins/artifact/editor/ArtifactGraphEditor.js index 9d449ae..4034653 100644 --- a/src/plugins/artifact/editor/ArtifactGraphEditor.js +++ b/src/plugins/artifact/editor/ArtifactGraphEditor.js @@ -4,16 +4,16 @@ import React from "react"; import type {Node} from "../../../core/graph"; import type {Settings} from "./SettingsConfig"; -import type {NodePayload, EdgePayload} from "../artifactPlugin"; +import type {NodePayload} from "../artifactPlugin"; import {Graph} from "../../../core/graph"; import {artifactAddress} from "../artifactPlugin"; type Props = { settings: Settings, - onChange: (Graph) => void, + onChange: (Graph) => void, }; type State = { - graph: Graph, + graph: Graph, artifactInProgressName: string, }; diff --git a/src/plugins/artifact/editor/ContributionList.js b/src/plugins/artifact/editor/ContributionList.js index 1f75d70..da8bb2c 100644 --- a/src/plugins/artifact/editor/ContributionList.js +++ b/src/plugins/artifact/editor/ContributionList.js @@ -7,7 +7,7 @@ import {AdapterSet} from "./adapterSet"; import {Graph} from "../../../core/graph"; type Props = { - graph: ?Graph, + graph: ?Graph, adapters: AdapterSet, }; type State = { @@ -39,7 +39,7 @@ export class ContributionList extends React.Component { if (this.props.graph == null) { return null; } - const graph: Graph = this.props.graph; + const graph: Graph = this.props.graph; const typesByPlugin: {[pluginName: string]: Set} = {}; graph.nodes().forEach((node) => { const adapter = this.props.adapters.getAdapter(node); @@ -88,7 +88,7 @@ export class ContributionList extends React.Component { if (this.props.graph == null) { return
(no graph)
; } else { - const graph: Graph = this.props.graph; + const graph: Graph = this.props.graph; const {typeFilter} = this.state; const shouldDisplay: (node: Node) => boolean = typeFilter ? (node) => { diff --git a/src/plugins/artifact/editor/ContributionList.test.js b/src/plugins/artifact/editor/ContributionList.test.js index 29eadb0..32c9450 100644 --- a/src/plugins/artifact/editor/ContributionList.test.js +++ b/src/plugins/artifact/editor/ContributionList.test.js @@ -19,8 +19,6 @@ function createTestData(): * { type PayloadA = number; type PayloadB = boolean; type PayloadC = string; - type NodePayload = PayloadA | PayloadB | PayloadC; - type EdgePayload = null; const PLUGIN_A = "sourcecred/example-plugin-a"; const PLUGIN_B = "sourcecred/example-plugin-b"; @@ -71,7 +69,7 @@ function createTestData(): * { dst: nodeA3().address, }); - const graph: () => Graph = () => + const graph: () => Graph = () => new Graph() .addNode(nodeA1()) .addNode(nodeA2()) @@ -84,7 +82,7 @@ function createTestData(): * { const adapterA: () => PluginAdapter = () => ({ pluginName: PLUGIN_A, renderer: class RendererA extends React.Component<{ - graph: Graph, + graph: Graph, node: Node, }> { render() { @@ -100,7 +98,7 @@ function createTestData(): * { ); } }, - extractTitle(graph: Graph, node: Node) { + extractTitle(graph: Graph, node: Node) { return `the number ${String(node.payload)}`; }, }); @@ -108,7 +106,7 @@ function createTestData(): * { const adapterB: () => PluginAdapter = () => ({ pluginName: PLUGIN_B, renderer: class RendererB extends React.Component<{ - graph: Graph, + graph: Graph, node: Node, }> { render() { @@ -120,7 +118,7 @@ function createTestData(): * { ); } }, - extractTitle(graph: Graph, node: Node) { + extractTitle(graph: Graph, node: Node) { return String(node.payload).toUpperCase() + "!"; }, }); diff --git a/src/plugins/artifact/editor/GithubGraphFetcher.js b/src/plugins/artifact/editor/GithubGraphFetcher.js index 5bcb44c..324303b 100644 --- a/src/plugins/artifact/editor/GithubGraphFetcher.js +++ b/src/plugins/artifact/editor/GithubGraphFetcher.js @@ -5,15 +5,11 @@ import React from "react"; import type {Graph} from "../../../core/graph"; import type {Settings} from "./SettingsConfig"; import fetchGithubRepo from "../../github/fetchGithubRepo"; -import type { - NodePayload as GithubNodePayload, - EdgePayload as GithubEdgePayload, -} from "../../github/types"; import {parse} from "../../github/parser"; type Props = { settings: Settings, - onCreateGraph: (graph: Graph) => void, + onCreateGraph: (graph: Graph) => void, }; export class GithubGraphFetcher extends React.Component { diff --git a/src/plugins/artifact/editor/adapters/githubPluginAdapter.js b/src/plugins/artifact/editor/adapters/githubPluginAdapter.js index 1589d72..0bf32e7 100644 --- a/src/plugins/artifact/editor/adapters/githubPluginAdapter.js +++ b/src/plugins/artifact/editor/adapters/githubPluginAdapter.js @@ -23,7 +23,7 @@ const adapter: PluginAdapter = { pluginName: PLUGIN_NAME, renderer: class GithubNodeRenderer extends React.Component<{ - graph: Graph, + graph: Graph, node: Node, }> { render() { diff --git a/src/plugins/artifact/editor/pluginAdapter.js b/src/plugins/artifact/editor/pluginAdapter.js index ea10458..38daae9 100644 --- a/src/plugins/artifact/editor/pluginAdapter.js +++ b/src/plugins/artifact/editor/pluginAdapter.js @@ -5,8 +5,6 @@ import type {ComponentType} from "react"; export interface PluginAdapter<-NodePayload> { pluginName: string; - renderer: $Subtype< - ComponentType<{graph: Graph, node: Node}> - >; - extractTitle(graph: Graph, node: Node): string; + renderer: $Subtype}>>; + extractTitle(graph: Graph, node: Node): string; } diff --git a/src/plugins/git/cloneGitGraph.js b/src/plugins/git/cloneGitGraph.js index 0377c2a..2d99b44 100644 --- a/src/plugins/git/cloneGitGraph.js +++ b/src/plugins/git/cloneGitGraph.js @@ -2,7 +2,6 @@ import cloneAndLoadRepository from "./cloneAndLoadRepository"; import {createGraph} from "./createGraph"; -import type {NodePayload, EdgePayload} from "./types"; import type {Graph} from "../../core/graph"; /** @@ -18,7 +17,7 @@ import type {Graph} from "../../core/graph"; export default function fetchGitGraph( repoOwner: string, repoName: string -): Graph { +): Graph { const repo = cloneAndLoadRepository(repoOwner, repoName); return createGraph(repo); } diff --git a/src/plugins/git/createGraph.js b/src/plugins/git/createGraph.js index 264d5f5..757c6c2 100644 --- a/src/plugins/git/createGraph.js +++ b/src/plugins/git/createGraph.js @@ -5,7 +5,6 @@ import type { BecomesEdgePayload, BlobNodePayload, Commit, - EdgePayload, HasContentsEdgePayload, Hash, IncludesEdgePayload, @@ -37,7 +36,7 @@ import { import {_makeAddress} from "./address"; class GitGraphCreator { - createGraph(repository: Repository): Graph { + createGraph(repository: Repository): Graph { const treeAndNameToSubmoduleUrls = this.treeAndNameToSubmoduleUrls( repository ); @@ -198,7 +197,7 @@ class GitGraphCreator { return result; } - becomesEdges(repository: Repository): Graph { + becomesEdges(repository: Repository): Graph { const result = new Graph(); for (const { childCommit, @@ -300,8 +299,6 @@ export function* findBecomesEdges( } } -export function createGraph( - repository: Repository -): Graph { +export function createGraph(repository: Repository): Graph { return new GitGraphCreator().createGraph(repository); } diff --git a/src/plugins/git/porcelain.js b/src/plugins/git/porcelain.js index 8bdb633..46efd95 100644 --- a/src/plugins/git/porcelain.js +++ b/src/plugins/git/porcelain.js @@ -60,8 +60,8 @@ function assertAddressType(address: Address, t: NodeType) { } export class GraphPorcelain { - graph: Graph; - constructor(graph: Graph) { + graph: Graph; + constructor(graph: Graph) { this.graph = graph; } diff --git a/src/plugins/github/fetchGithubGraph.js b/src/plugins/github/fetchGithubGraph.js index 8731a3a..b6a465a 100644 --- a/src/plugins/github/fetchGithubGraph.js +++ b/src/plugins/github/fetchGithubGraph.js @@ -4,7 +4,6 @@ * docstring of the default export for more details. */ -import type {NodePayload, EdgePayload} from "./types"; import type {Graph} from "../../core/graph"; import fetchGithubRepo from "./fetchGithubRepo"; import {parse} from "./parser"; @@ -19,13 +18,13 @@ import {parse} from "./parser"; * @param {String} token * authentication token to be used for the GitHub API; generate a * token at: https://github.com/settings/tokens - * @return {Promise} + * @return {Promise} * a promise that resolves to a GitHub contribution graph */ export default function fetchGithubGraph( repoOwner: string, repoName: string, token: string -): Promise> { +): Promise { return fetchGithubRepo(repoOwner, repoName, token).then((x) => parse(x)); } diff --git a/src/plugins/github/parser.js b/src/plugins/github/parser.js index e0076f9..033eb63 100644 --- a/src/plugins/github/parser.js +++ b/src/plugins/github/parser.js @@ -6,8 +6,6 @@ import type {Node, Edge} from "../../core/graph"; import type { NodeType, EdgeType, - NodePayload, - EdgePayload, PullRequestReviewNodePayload, RepositoryNodePayload, AuthorNodePayload, @@ -37,9 +35,7 @@ import {Graph, edgeID} from "../../core/graph"; import {findReferences} from "./findReferences"; import {commitAddress} from "../git/address"; -export function parse( - githubResponseJSON: GithubResponseJSON -): Graph { +export function parse(githubResponseJSON: GithubResponseJSON): Graph { const parser = new GithubParser(); parser.addData(githubResponseJSON); parser.addReferenceEdges(); @@ -47,7 +43,7 @@ export function parse( } class GithubParser { - graph: Graph; + graph: Graph; constructor() { this.graph = new Graph(); diff --git a/src/plugins/github/parser.test.js b/src/plugins/github/parser.test.js index 7561652..14da766 100644 --- a/src/plugins/github/parser.test.js +++ b/src/plugins/github/parser.test.js @@ -1,7 +1,6 @@ // @flow import {AUTHORS_EDGE_TYPE, CONTAINS_EDGE_TYPE} from "./types"; -import type {NodePayload, EdgePayload} from "./types"; import {parse} from "./parser"; import type {GithubResponseJSON, PullRequestJSON, IssueJSON} from "./graphql"; import {Graph} from "../../core/graph"; @@ -92,7 +91,7 @@ describe("GithubParser", () => { function parseExample({ issues: issueNums = [], prs: prNums = [], - }: ExampleInput): Graph { + }: ExampleInput): Graph { const issues = issueNums.map(getIssue); const pullRequests = prNums.map(getPR); const exampleData: GithubResponseJSON = { diff --git a/src/plugins/github/porcelain.js b/src/plugins/github/porcelain.js index 40e5d2a..d7ae79e 100644 --- a/src/plugins/github/porcelain.js +++ b/src/plugins/github/porcelain.js @@ -22,7 +22,6 @@ import type { AuthorNodePayload, AuthorSubtype, CommentNodePayload, - EdgePayload, IssueNodePayload, MergedAsEdgePayload, NodePayload, @@ -99,9 +98,9 @@ function asGithubReference( } export class GraphPorcelain { - graph: Graph; + graph: Graph; - constructor(graph: Graph) { + constructor(graph: Graph) { this.graph = graph; } diff --git a/src/tools/loadCombinedGraph.js b/src/tools/loadCombinedGraph.js index 07d7f04..d7253ad 100644 --- a/src/tools/loadCombinedGraph.js +++ b/src/tools/loadCombinedGraph.js @@ -21,14 +21,14 @@ export type EdgePayload = GitEdgePayload | GithubEdgePayload; * the GitHub username of the owner of the repository to be cloned * @param {String} repoName * the name of the repository to be cloned - * @return {Promise>} + * @return {Promise} * a Promise containing the combined contribution graph */ export function loadCombinedGraph( repoOwner: string, repoName: string, token: string -): Promise> { +): Promise { const githubGraphPromise = fetchGithubGraph(repoOwner, repoName, token); const gitGraph = cloneGitGraph(repoOwner, repoName); return githubGraphPromise.then((x) => Graph.mergeConservative(gitGraph, x));