-
Notifications
You must be signed in to change notification settings - Fork 90
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
Codeclimate #590
Draft
Blaimi
wants to merge
4
commits into
IBM:main
Choose a base branch
from
Blaimi:codeclimate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Codeclimate #590
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0333639
Draft: feat(codeclimate): outputFormat for CodeClimate (#512)
Blaimi 6d1146e
Draft: feat(codeclimate): config-file respecting CodeClimate parameters
Blaimi 0c08691
Containerfile to create image from current source
Blaimi b6bc6ea
gitlab-ci to create container image for usage in gitlab-ci
Blaimi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.* | ||
/node_modules | ||
/appscan-config.xml | ||
/*.md | ||
/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
image-build: | ||
image: | ||
name: quay.io/buildah/stable:latest | ||
stage: build | ||
before_script: | ||
- 'echo "$CI_REGISTRY_PASSWORD" | buildah login --username "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY' | ||
script: | ||
- buildah bud | ||
-f "Containerfile" | ||
-t "$CI_REGISTRY_IMAGE/codeclimate-openapi:latest" | ||
--layers | ||
--cache-from=$CI_REGISTRY_IMAGE/codeclimate-openapi/cache | ||
--cache-to=$CI_REGISTRY_IMAGE/codeclimate-openapi/cache | ||
. | ||
- buildah push "$CI_REGISTRY_IMAGE/codeclimate-openapi:latest" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:current-alpine3.17 AS builder | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm ci | ||
|
||
COPY . ./ | ||
RUN cd packages/validator && npm pack && mv ibm-openapi-validator-*.tgz /tmp/ibm-openapi-validator-latest.tgz | ||
|
||
FROM node:current-alpine3.17 | ||
|
||
RUN apk add --no-cache git | ||
|
||
COPY --from=builder /tmp/ibm-openapi-validator-latest.tgz /tmp | ||
# not possible to install from github directly https://github.com/npm/npm/issues/2974 | ||
RUN npm install -g /tmp/ibm-openapi-validator-latest.tgz \ | ||
&& npm cache clean --force | ||
|
||
WORKDIR /code | ||
ENTRYPOINT ["lint-openapi", "--config", "/config.json", "--codeclimate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/validator/src/cli-validator/utils/codeclimate-results.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2023 IBM Corporation, Matthias Blümel. | ||
* SPDX-License-Identifier: Apache2.0 | ||
*/ | ||
|
||
const each = require('lodash/each'); | ||
|
||
function printCCJson(validFile, results) { | ||
const types = ['error', 'warning', 'info', 'hint']; | ||
const ccTypeMap = { | ||
error: 'critical', | ||
warning: 'major', | ||
info: 'minor', | ||
hint: 'info', | ||
}; | ||
|
||
types.forEach(type => { | ||
each(results[type].results, result => { | ||
let content; | ||
if (result.path.length !== 0) { | ||
let markdown = ''; | ||
each(result.path, pathItem => { | ||
markdown += '* ' + pathItem + '\n'; | ||
}); | ||
content = { body: markdown }; | ||
} | ||
const ccResult = { | ||
type: 'issue', | ||
check_name: result.rule, | ||
description: result.message, | ||
content: content, | ||
categories: ['Style'], // required by codeclimate, ignored by gitlab; has to be defined by the rule. | ||
location: { | ||
path: validFile, | ||
lines: { | ||
begin: result.line, | ||
end: result.line, | ||
}, | ||
}, | ||
severity: ccTypeMap[type], | ||
}; | ||
console.log(JSON.stringify(ccResult) + '\0\n'); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports.printCCJson = printCCJson; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/validator/test/cli-validator/mock-files/config/invalid-values.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"errors": 0, | ||
"warnings": "text", | ||
"population": 10 | ||
"population": 10, | ||
"errorsOnly": "yes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary for the code climate support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at all, but a
config.json
passed by codeclimate file looks like this:when executing in biletado/apidocs.
One can still add a
files
section in.codeclimate.yml
like I do at the moment for testing until the implementation for the recursive filesearch is implemented. This is then added to theconfig.json
. You can have a look at the.codeclimate.yml
I used in the mentioned project for testing this as an engine.