From de587f500a31b2ec886e46d450dc7b982435fc2c Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt Date: Sat, 11 May 2019 21:17:18 +0300 Subject: [PATCH] Rename Severity::Refactoring -> Severity::Convention it preserves clang format --- spec/ameba/cli/cmd_spec.cr | 6 ++--- spec/ameba/formatter/dot_formatter_spec.cr | 2 +- .../ameba/formatter/explain_formatter_spec.cr | 2 +- .../formatter/flycheck_formatter_spec.cr | 4 ++-- spec/ameba/formatter/json_formatter_spec.cr | 2 +- spec/ameba/formatter/todo_formatter_spec.cr | 2 +- spec/ameba/runner_spec.cr | 4 ++-- spec/ameba/severity_spec.cr | 24 +++++++++---------- src/ameba/cli/cmd.cr | 2 +- src/ameba/config.cr | 4 ++-- src/ameba/formatter/json_formatter.cr | 4 ++-- src/ameba/severity.cr | 6 ++--- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/spec/ameba/cli/cmd_spec.cr b/spec/ameba/cli/cmd_spec.cr index f2a1036e..f44ff6c6 100644 --- a/spec/ameba/cli/cmd_spec.cr +++ b/spec/ameba/cli/cmd_spec.cr @@ -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 diff --git a/spec/ameba/formatter/dot_formatter_spec.cr b/spec/ameba/formatter/dot_formatter_spec.cr index 66839292..44442622 100644 --- a/spec/ameba/formatter/dot_formatter_spec.cr +++ b/spec/ameba/formatter/dot_formatter_spec.cr @@ -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 diff --git a/spec/ameba/formatter/explain_formatter_spec.cr b/spec/ameba/formatter/explain_formatter_spec.cr index 0f5d3e4f..770d4277 100644 --- a/spec/ameba/formatter/explain_formatter_spec.cr +++ b/spec/ameba/formatter/explain_formatter_spec.cr @@ -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 diff --git a/spec/ameba/formatter/flycheck_formatter_spec.cr b/spec/ameba/formatter/flycheck_formatter_spec.cr index f8cdcfa3..d9fda5fd 100644 --- a/spec/ameba/formatter/flycheck_formatter_spec.cr +++ b/spec/ameba/formatter/flycheck_formatter_spec.cr @@ -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 diff --git a/spec/ameba/formatter/json_formatter_spec.cr b/spec/ameba/formatter/json_formatter_spec.cr index 6e84e928..6011e459 100644 --- a/spec/ameba/formatter/json_formatter_spec.cr +++ b/spec/ameba/formatter/json_formatter_spec.cr @@ -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 diff --git a/spec/ameba/formatter/todo_formatter_spec.cr b/spec/ameba/formatter/todo_formatter_spec.cr index 516b4be7..7b2ecac3 100644 --- a/spec/ameba/formatter/todo_formatter_spec.cr +++ b/spec/ameba/formatter/todo_formatter_spec.cr @@ -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 diff --git a/spec/ameba/runner_spec.cr b/spec/ameba/runner_spec.cr index 1d3dc2ca..7dba438c 100644 --- a/spec/ameba/runner_spec.cr +++ b/spec/ameba/runner_spec.cr @@ -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 diff --git a/spec/ameba/severity_spec.cr b/spec/ameba/severity_spec.cr index 78a1ef25..fe8c5cc5 100644 --- a/spec/ameba/severity_spec.cr +++ b/spec/ameba/severity_spec.cr @@ -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 diff --git a/src/ameba/cli/cmd.cr b/src/ameba/cli/cmd.cr index ea1f4cd8..033a56c0 100644 --- a/src/ameba/cli/cmd.cr +++ b/src/ameba/cli/cmd.cr @@ -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 diff --git a/src/ameba/config.cr b/src/ameba/config.cr index 24220b2c..d3c72040 100644 --- a/src/ameba/config.cr +++ b/src/ameba/config.cr @@ -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 %} diff --git a/src/ameba/formatter/json_formatter.cr b/src/ameba/formatter/json_formatter.cr index b45b483c..211dabb9 100644 --- a/src/ameba/formatter/json_formatter.cr +++ b/src/ameba/formatter/json_formatter.cr @@ -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", diff --git a/src/ameba/severity.cr b/src/ameba/severity.cr index 71314253..917cf4e9 100644 --- a/src/ameba/severity.cr +++ b/src/ameba/severity.cr @@ -2,7 +2,7 @@ module Ameba enum Severity Error Warning - Refactoring + Convention # Returns a symbol uniquely indicating severity. # @@ -16,8 +16,8 @@ module Ameba # Creates Severity by the name. # # ``` - # Severity.parse("refactoring") # => Severity::Refactoring - # Severity.parse("foo-bar") # => Exception: Incorrect severity name + # Severity.parse("convention") # => Severity::Convention + # Severity.parse("foo-bar") # => Exception: Incorrect severity name # ``` # def self.parse(name : String)