Skip to content

Use rule identifier as check name #22

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

Merged
merged 3 commits into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
Makefile
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apk --update add nodejs git ruby ruby-dev ruby-bundler less ruby-nokogiri bu
bundle install -j 4 && \
apk del build-base && rm -fr /usr/share/ri

RUN npm install -g codeclimate/csslint.git#27a21742
RUN npm install -g codeclimate/csslint.git#43d315c2

RUN adduser -u 9000 -D app
USER app
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.PHONY: test

image:
docker build -t codeclimate/codeclimate-csslint .

test: image
docker run --rm codeclimate/codeclimate-csslint rake
18 changes: 7 additions & 11 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,21 @@ machine:
CODECLIMATE_DOCKER_REGISTRY_USERNAME: circleci
CODECLIMATE_DOCKER_REGISTRY_EMAIL: ops@codeclimate.com

dependencies:
override:
- echo $gcloud_json_key_base64 | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json
- curl https://sdk.cloud.google.com | bash
- bundle install
- npm install -g codeclimate/csslint.git#7a3a6be

test:
override:
- bundle exec rspec spec
- docker build -t=$registry_root/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM .
- make test

deployment:
registry:
branch: master
commands:
# GCR for .com
- echo $gcloud_json_key_base64 | sed 's/ //g' | base64 -d > /tmp/gcloud_key.json
- docker tag codeclimate/codeclimate-csslint $registry_root/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM
- gcloud auth activate-service-account --key-file /tmp/gcloud_key.json
- gcloud docker -a
- docker push $registry_root/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM
- gcloud docker push $registry_root/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM

# registry.codeclimate.net for CC:E
- docker login --username=$CODECLIMATE_DOCKER_REGISTRY_USERNAME --password=$CODECLIMATE_DOCKER_REGISTRY_PASSWORD --email=$CODECLIMATE_DOCKER_REGISTRY_EMAIL $CODECLIMATE_DOCKER_REGISTRY_HOSTNAME
- docker tag $registry_root/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM $CODECLIMATE_DOCKER_REGISTRY_HOSTNAME/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM
- docker push $CODECLIMATE_DOCKER_REGISTRY_HOSTNAME/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME:b$CIRCLE_BUILD_NUM
Expand Down
2 changes: 1 addition & 1 deletion lib/cc/engine/csslint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def run
next unless node.name == "error"

lint = node.attributes
check_name = lint["source"].value
check_name = lint["identifier"].value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be prefixed in the resulting json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Any check-prefixing is meant to be done from the outside. RuboCop's current behavior notwithstanding, that's the future we want to build for -- so says @brynary anyway.

check_details = CheckDetails.fetch(check_name)

issue = {
Expand Down
50 changes: 25 additions & 25 deletions lib/cc/engine/csslint/check_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ class CSSlint
class CheckDetails
ALL_RULES = {
# https://github.com/CSSLint/csslint/wiki/Rules
"net.csslint.Bewareofbrokenboxsize" => { categories: "Bug Risk" },
"net.csslint.Disallow@import" => { categories: "Bug Risk" },
"net.csslint.Disallowadjoiningclasses" => { categories: "Compatibility" },
"net.csslint.Disallowduplicatebackgroundimages" => { categories: "Bug Risk" },
"net.csslint.Disallowduplicateproperties" => { categories: "Bug Risk" },
"net.csslint.Disallowemptyrules" => { categories: "Bug Risk" },
"net.csslint.Disallownegativetext-indent" => { categories: "Compatibility" },
"net.csslint.Disallowoverqualifiedelements" => { categories: "Bug Risk" },
"net.csslint.Disallowpropertieswithanunderscoreprefix" => { categories: "Compatibility" },
"net.csslint.Disallowpropertieswithastarprefix" => { categories: "Compatibility" },
"net.csslint.Disallowselectorsthatlooklikeregexs" => { categories: "Bug Risk" },
"net.csslint.Disallowunitsfor0values" => { categories: "Bug Risk" },
"net.csslint.Disallowuniversalselector" => { categories: "Bug Risk" },
"net.csslint.Disallowunqualifiedattributeselectors" => { categories: "Bug Risk" },
"net.csslint.Disallowuseofbox-sizing" => { categories: "Compatibility" },
"net.csslint.Don'tusetoomanywebfonts" => { categories: "Bug Risk" },
"net.csslint.Headingsshouldonlybedefinedonce" => { categories: "Duplication" },
"net.csslint.Requireallgradientdefinitions" => { categories: "Compatibility" },
"net.csslint.Requirecompatiblevendorprefixes" => { categories: "Compatibility" },
"net.csslint.Requirefallbackcolors" => { categories: "Compatibility" },
"net.csslint.Requirepropertiesappropriatefordisplay" => { categories: "Bug Risk" },
"net.csslint.Requireshorthandproperties" => { categories: "Bug Risk" },
"net.csslint.Requirestandardpropertywithvendorprefix" => { categories: "Compatibility" },
"net.csslint.Requireuseofknownproperties" => { categories: "Bug Risk" },
"net.csslint.Usethebulletproof@font-facesyntax" => { categories: "Compatibility" },
"adjoining-classes" => { categories: "Compatibility" },
"box-model" => { categories: "Bug Risk" },
"box-sizing" => { categories: "Compatibility" },
"bulletproof-font-face" => { categories: "Compatibility" },
"compatible-vendor-prefixes" => { categories: "Compatibility" },
"display-property-grouping" => { categories: "Bug Risk" },
"duplicate-background-images" => { categories: "Bug Risk" },
"duplicate-properties" => { categories: "Bug Risk" },
"empty-rules" => { categories: "Bug Risk" },
"fallback-colors" => { categories: "Compatibility" },
"font-faces" => { categories: "Bug Risk" },
"gradients" => { categories: "Compatibility" },
"import" => { categories: "Bug Risk" },
"known-properties" => { categories: "Bug Risk" },
"overqualified-elements" => { categories: "Bug Risk" },
"regex-selectors" => { categories: "Bug Risk" },
"shorthand" => { categories: "Bug Risk" },
"star-property-hack" => { categories: "Compatibility" },
"text-indent" => { categories: "Compatibility" },
"underscore-property-hack" => { categories: "Compatibility" },
"unique-headings" => { categories: "Duplication" },
"universal-selector" => { categories: "Bug Risk" },
"unqualified-attributes" => { categories: "Bug Risk" },
"vendor-prefix" => { categories: "Compatibility" },
"zero-units" => { categories: "Bug Risk" },
}.freeze

DEFAULT_CATEGORY = "Style".freeze
Expand Down
2 changes: 1 addition & 1 deletion spec/cc/engine/csslint/check_details_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CC::Engine::CSSlint
describe CheckDetails do
describe ".fetch" do
it "returns details for customized checks" do
details = CheckDetails.fetch("net.csslint.Disallow@import")
details = CheckDetails.fetch("import")

expect(details.categories).to eq ["Bug Risk"]
expect(details.remediation_points).to eq 50_000
Expand Down