Skip to content

Commit

Permalink
Merge pull request #22 from codeclimate/pb-check-names
Browse files Browse the repository at this point in the history
Use rule identifier as check name
  • Loading branch information
pbrisbin committed Dec 8, 2015
2 parents e978aea + c8fd68f commit 38ac19c
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 39 deletions.
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: [email protected]

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
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

0 comments on commit 38ac19c

Please sign in to comment.