Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitLab CI/CD Code Quality support #2024

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -16,3 +16,4 @@ website/**/package-lock.json
public/
.now
.vercel
/.idea/
13 changes: 10 additions & 3 deletions packages/commands/diff/__tests__/diff-command.spec.ts
Original file line number Diff line number Diff line change
@@ -125,13 +125,13 @@ describe('diff', () => {
expect(spyReporter).not.toHaveBeenCalledNormalized('does not exist');
});

test('should render error if file does not exist', async () => {
test('should render error if --rule file does not exist', async () => {
await mockCommand(diff, `diff old.graphql new.graphql --rule noop.js`);

expect(spyReporter).toHaveBeenCalledNormalized('does not exist');
});

test('should render error if file does not exist', async () => {
test('should render error if file onComplete does not exist (#1)', async () => {
await mockCommand(
diff,
`diff old.graphql new.graphql --onComplete ${resolve(
@@ -143,12 +143,19 @@ describe('diff', () => {
expect(spyProcessExit).toHaveBeenCalledWith(2);
});

test('should render error if file does not exist', async () => {
test('should render error if onComplete file does not exist (#2)', async () => {
await mockCommand(
diff,
`diff old.graphql new.graphql --onComplete noop.js`,
);

expect(spyReporter).toHaveBeenCalledNormalized('does not exist');
});

test('should render Code Quality JSON on --format gitlab success', async () => {
await mockCommand(diff, `diff old.graphql new.graphql --format gitlab`);

// TODO
expect(spyReporter).toHaveBeenCalledNormalized('[{');
});
});
3 changes: 3 additions & 0 deletions packages/commands/diff/package.json
Original file line number Diff line number Diff line change
@@ -47,5 +47,8 @@
},
"scripts": {
"prepack": "bob prepack"
},
"devDependencies": {
"@types/node": "16.10.2"
}
}
58 changes: 58 additions & 0 deletions packages/commands/diff/src/gitlab-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Source code traces not implemented: https://github.com/codeclimate/platform/blob/master/spec/analyzers/SPEC.md#source-code-traces
export interface GitLabCodeClimateIssueType {
type: 'issue';
check_name: string;
description: string;
content?: string;
categories: Array<IssueType>;
location: Location;
other_locations?: Array<Location>;
severity?: Severity;
fingerprint?: string;
}

export enum IssueType {
BUG_RISK = 'Bug Risk',
CLARITY = 'Clarity',
COMPATIBILITY = 'Compatibilty',
COMPLEXITY = 'Complexity',
DUPLICATION = 'Duplication',
PERFORMANCE = 'Performance',
SECURITY = 'Security',
STYLE = 'Style',
}

export enum Severity {
INFO = 'info',
MINOR = 'minor',
MAJOR = 'major',
CRITICAL = 'critical',
BLOCKER = 'blocker',
}

export interface Location {
path: String;
lines?: Lines;
positions?: BeginEnd;
}

export interface Lines {
begin: number;
end: number;
}

export interface BeginEnd {
begin: Position;
end: Position;
}

export type Position = LineColumnPosition | OffsetPosition;

export interface LineColumnPosition {
line: number;
column?: number;
}

export interface OffsetPosition {
offset: number;
}
Loading