-
Notifications
You must be signed in to change notification settings - Fork 9
Raise default remediation, categorize checks #19
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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,53 @@ | ||
module CC | ||
module Engine | ||
class CSSlint | ||
class CheckDetails | ||
ALL_RULES = { | ||
# https://github.com/CSSLint/csslint/wiki/Rules | ||
"net.csslint.Adjoiningclasses" => { categories: "Compatability" }, | ||
"net.csslint.Boxmodel" => { categories: "Bug Risk" }, | ||
"net.csslint.Boxsizing" => { categories: "Compatability" }, | ||
"net.csslint.Bulletprooffontface" => { categories: "Compatability" }, | ||
"net.csslint.Compatiblevendorprefixes" => { categories: "Compatability" }, | ||
"net.csslint.Displaypropertygrouping" => { categories: "Bug Risk" }, | ||
"net.csslint.Duplicatebackgroundimages" => { categories: "Bug Risk" }, | ||
"net.csslint.Duplicateproperties" => { categories: "Bug Risk" }, | ||
"net.csslint.Emptyrules" => { categories: "Bug Risk" }, | ||
"net.csslint.Fallbackcolors" => { categories: "Compatability" }, | ||
"net.csslint.Fontfaces" => { categories: "Bug Risk" }, | ||
"net.csslint.Gradients" => { categories: "Compatability" }, | ||
"net.csslint.Import" => { categories: "Bug Risk" }, | ||
"net.csslint.Knownproperties" => { categories: "Bug Risk" }, | ||
"net.csslint.Overqualifiedelements" => { categories: "Bug Risk" }, | ||
"net.csslint.Regexselectors" => { categories: "Bug Risk" }, | ||
"net.csslint.Shorthand" => { categories: "Bug Risk" }, | ||
"net.csslint.Starpropertyhack" => { categories: "Compatability" }, | ||
"net.csslint.Textindent" => { categories: "Compatability" }, | ||
"net.csslint.Underscorepropertyhack" => { categories: "Compatability" }, | ||
"net.csslint.Uniqueheadings" => { categories: "Duplication" }, | ||
"net.csslint.Universalselector" => { categories: "Bug Risk" }, | ||
"net.csslint.Unqualifiedattributes" => { categories: "Bug Risk" }, | ||
"net.csslint.Vendorprefix" => { categories: "Compatability" }, | ||
"net.csslint.Zerounits" => { categories: "Bug Risk" }, | ||
}.freeze | ||
|
||
DEFAULT_CATEGORY = "Style".freeze | ||
DEFAULT_REMEDIATION_POINTS = 50_000.freeze | ||
|
||
attr_reader :categories, :remediation_points | ||
|
||
def self.fetch(check_name) | ||
new(ALL_RULES.fetch(check_name, {})) | ||
end | ||
|
||
def initialize( | ||
categories: DEFAULT_CATEGORY, | ||
remediation_points: DEFAULT_REMEDIATION_POINTS | ||
) | ||
@categories = Array(categories) | ||
@remediation_points = remediation_points | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or 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,21 @@ | ||
require "spec_helper" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! glad to have some tests. |
||
|
||
class CC::Engine::CSSlint | ||
describe CheckDetails do | ||
describe ".fetch" do | ||
it "returns details for customized checks" do | ||
details = CheckDetails.fetch("net.csslint.Import") | ||
|
||
expect(details.categories).to eq ["Bug Risk"] | ||
expect(details.remediation_points).to eq 50_000 | ||
end | ||
|
||
it "returns defaults for unknown checks" do | ||
details = CheckDetails.fetch("made-up") | ||
|
||
expect(details.categories).to eq ["Style"] | ||
expect(details.remediation_points).to eq 50_000 | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or 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,4 @@ | ||
require 'cc/engine/csslint' | ||
require 'tmpdir' | ||
require "spec_helper" | ||
|
||
module CC | ||
module Engine | ||
|
This file contains hidden or 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,2 @@ | ||
require "cc/engine/csslint" | ||
require "tmpdir" |
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.
It seems like the major function of this class at present is to get the category for an issue.
What do you think about having a
category
class instead, and have it initialize with a check?Then, in the
CSSLint
or anIssue
class, we can have