Rename Severity::Refactoring -> Severity::Convention

it preserves clang format
This commit is contained in:
Vitalii Elenhaupt 2019-05-11 21:17:18 +03:00
parent 94e1d4567a
commit de587f500a
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
12 changed files with 31 additions and 31 deletions

View file

@ -115,9 +115,9 @@ module Ameba::Cli
end
context "--fail-level" do
it "configures fail level Refactoring" do
c = Cli.parse_args %w(--fail-level refactoring)
c.fail_level.should eq Severity::Refactoring
it "configures fail level Convention" do
c = Cli.parse_args %w(--fail-level convention)
c.fail_level.should eq Severity::Convention
end
it "configures fail level Warning" do

View file

@ -74,7 +74,7 @@ module Ameba::Formatter
end
subject.finished [s]
log = output.to_s
log.should contain "[R]"
log.should contain "[C]"
end
it "doesn't write affected code if it is disabled" do

View file

@ -50,7 +50,7 @@ module Ameba
source = Source.new "a = 42", "source.cr"
output = explanation(source)
output.should contain "RULE INFO"
output.should contain "Refactoring"
output.should contain "Convention"
output.should contain "Ameba/ErrorRule"
output.should contain "Always adds an error at 1:1"
end

View file

@ -22,7 +22,7 @@ module Ameba::Formatter
subject = flycheck
subject.source_finished s
subject.output.to_s.should eq(
"source.cr:1:2: R: [#{DummyRule.rule_name}] message\n"
"source.cr:1:2: C: [#{DummyRule.rule_name}] message\n"
)
end
@ -32,7 +32,7 @@ module Ameba::Formatter
subject = flycheck
subject.source_finished s
subject.output.to_s.should eq(
"source.cr:1:2: R: [#{DummyRule.rule_name}] multi line\n"
"source.cr:1:2: C: [#{DummyRule.rule_name}] multi line\n"
)
end

View file

@ -42,7 +42,7 @@ module Ameba
s.add_issue DummyRule.new, {1, 2}, "message"
result = get_result [s]
result["sources"][0]["issues"][0]["severity"].should eq "Refactoring"
result["sources"][0]["issues"][0]["severity"].should eq "Convention"
end
it "shows a message" do

View file

@ -44,7 +44,7 @@ module Ameba
end
it "creates a todo with severity" do
create_todo.should contain "Refactoring"
create_todo.should contain "Convention"
end
it "creates a todo with problems count" do

View file

@ -13,7 +13,7 @@ module Ameba
describe Runner do
formatter = DummyFormatter.new
default_severity = Severity::Refactoring
default_severity = Severity::Convention
describe "#run" do
it "returns self" do
@ -148,7 +148,7 @@ module Ameba
s = Source.new %q(WrongConstant = 5)
Runner.new(rules, [s], formatter, Severity::Error).run.success?.should be_true
Runner.new(rules, [s], formatter, Severity::Warning).run.success?.should be_true
Runner.new(rules, [s], formatter, Severity::Refactoring).run.success?.should be_false
Runner.new(rules, [s], formatter, Severity::Convention).run.success?.should be_false
end
it "returns false if issue is disabled" do

View file

@ -17,8 +17,8 @@ module Ameba
Severity::Warning.symbol.should eq 'W'
end
it "returns symbol for Refactoring" do
Severity::Refactoring.symbol.should eq 'R'
it "returns symbol for Convention" do
Severity::Convention.symbol.should eq 'C'
end
end
@ -31,12 +31,12 @@ module Ameba
Severity.parse("Warning").should eq Severity::Warning
end
it "creates refactoring severity by name" do
Severity.parse("Refactoring").should eq Severity::Refactoring
it "creates convention severity by name" do
Severity.parse("Convention").should eq Severity::Convention
end
it "raises when name is incorrect" do
expect_raises(Exception, "Incorrect severity name BadName. Try one of [Error, Warning, Refactoring]") do
expect_raises(Exception, "Incorrect severity name BadName. Try one of [Error, Warning, Convention]") do
Severity.parse("BadName")
end
end
@ -63,14 +63,14 @@ module Ameba
converted.severity.should eq Severity::Warning
end
it "converts from yaml to Severity::Refactoring" do
yaml = {severity: "refactoring"}.to_yaml
it "converts from yaml to Severity::Convention" do
yaml = {severity: "convention"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml)
converted.severity.should eq Severity::Refactoring
converted.severity.should eq Severity::Convention
end
it "raises if severity is not a scalar" do
yaml = {severity: {refactoring: true}}.to_yaml
yaml = {severity: {convention: true}}.to_yaml
expect_raises(Exception, "Severity must be a scalar") do
SeverityConvertable.from_yaml(yaml)
end
@ -97,10 +97,10 @@ module Ameba
converted.should eq "---\nseverity: Warning\n"
end
it "converts Severity::Refactoring to yaml" do
yaml = {severity: "refactoring"}.to_yaml
it "converts Severity::Convention to yaml" do
yaml = {severity: "convention"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml).to_yaml
converted.should eq "---\nseverity: Refactoring\n"
converted.should eq "---\nseverity: Convention\n"
end
end
end

View file

@ -84,7 +84,7 @@ module Ameba::Cli
opts.config = ""
end
parser.on("--fail-level SEVERITY", "Change the level of failure to exit. Defaults to Refactoring") do |level|
parser.on("--fail-level SEVERITY", "Change the level of failure to exit. Defaults to Convention") do |level|
opts.fail_level = Severity.parse(level)
end

View file

@ -28,7 +28,7 @@ class Ameba::Config
setter formatter : Formatter::BaseFormatter?
setter globs : Array(String)?
getter rules : Array(Rule::Base)
property severity = Severity::Refactoring
property severity = Severity::Convention
@rule_groups : Hash(String, Array(Rule::Base))
@ -229,7 +229,7 @@ class Ameba::Config
{% end %}
{% if properties["severity".id] == nil %}
{% default = @type.name.starts_with?("Ameba::Rule::Lint") ? "Severity::Warning".id : "Severity::Refactoring".id %}
{% default = @type.name.starts_with?("Ameba::Rule::Lint") ? "Severity::Warning".id : "Severity::Convention".id %}
{% properties["severity".id] = {key: "Severity", default: default, type: Severity, converter: SeverityYamlConverter} %}
{% end %}

View file

@ -25,7 +25,7 @@ module Ameba::Formatter
# },
# "message": "Useless assignment to variable `a`",
# "rule_name": "UselessAssign",
# "severity": "Refactoring",
# "severity": "Convention",
# },
# {
# "location": {
@ -50,7 +50,7 @@ module Ameba::Formatter
# },
# "message": "Useless assignment to variable `a`",
# "rule_name": "UselessAssign",
# "severity": "Refactoring",
# "severity": "Convention",
# },
# ],
# "path": "src/ameba/formatter/json_formatter.cr",

View file

@ -2,7 +2,7 @@ module Ameba
enum Severity
Error
Warning
Refactoring
Convention
# Returns a symbol uniquely indicating severity.
#
@ -16,7 +16,7 @@ module Ameba
# Creates Severity by the name.
#
# ```
# Severity.parse("refactoring") # => Severity::Refactoring
# Severity.parse("convention") # => Severity::Convention
# Severity.parse("foo-bar") # => Exception: Incorrect severity name
# ```
#