UNPKG

1.95 kBTypeScriptView Raw
1import { RepoRef } from "@atomist/automation-client/lib/operations/common/RepoId";
2import { Project } from "@atomist/automation-client/lib/project/Project";
3import { NoParameters } from "@atomist/automation-client/lib/SmartParameters";
4import { CommandListenerInvocation } from "../listener/CommandListener";
5import { ProjectsOperationRegistration } from "./ProjectsOperationRegistration";
6import { PushAwareParametersInvocation } from "./PushAwareParametersInvocation";
7/**
8 * Function that can run against a project without mutating it to
9 * compute a value.
10 */
11export declare type CodeInspection<R, P = NoParameters> = (p: Project, papi: PushAwareParametersInvocation<P>) => Promise<R>;
12/**
13 * Result of inspecting a single project
14 */
15export interface CodeInspectionResult<R> {
16 repoId: RepoRef;
17 /**
18 * Inspection result can be undefined if a repo was returned by an all repo query but the
19 * inspection was not run on that repo because it did not match the project predicate specified in the registration.
20 */
21 result: R | undefined;
22}
23/**
24 * Actions added by inspections. For internal use.
25 */
26export interface CodeInspectionActions<R, PARAMS> {
27 /**
28 * Inspection function to run on each project
29 */
30 inspection: CodeInspection<R, PARAMS>;
31 /**
32 * React to computed values from running across one or more projects
33 * @param {R[]} results
34 * @param ci context
35 * @return {Promise<void>}
36 */
37 onInspectionResults?(results: Array<CodeInspectionResult<R>>, ci: CommandListenerInvocation<PARAMS>): Promise<void>;
38}
39/**
40 * Register a AutoCodeInspection that can run against any number of projects.
41 * Include an optional react method that can react to review results.
42 */
43export interface CodeInspectionRegistration<R, PARAMS = NoParameters> extends ProjectsOperationRegistration<PARAMS>, CodeInspectionActions<R, PARAMS> {
44}
45//# sourceMappingURL=CodeInspectionRegistration.d.ts.map
\No newline at end of file