mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Rename Severity::Refactoring -> Severity::Convention
it preserves clang format
This commit is contained in:
		
							parent
							
								
									94e1d4567a
								
							
						
					
					
						commit
						de587f500a
					
				
					 12 changed files with 31 additions and 31 deletions
				
			
		| 
						 | 
					@ -115,9 +115,9 @@ module Ameba::Cli
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      context "--fail-level" do
 | 
					      context "--fail-level" do
 | 
				
			||||||
        it "configures fail level Refactoring" do
 | 
					        it "configures fail level Convention" do
 | 
				
			||||||
          c = Cli.parse_args %w(--fail-level refactoring)
 | 
					          c = Cli.parse_args %w(--fail-level convention)
 | 
				
			||||||
          c.fail_level.should eq Severity::Refactoring
 | 
					          c.fail_level.should eq Severity::Convention
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it "configures fail level Warning" do
 | 
					        it "configures fail level Warning" do
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,7 @@ module Ameba::Formatter
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
          subject.finished [s]
 | 
					          subject.finished [s]
 | 
				
			||||||
          log = output.to_s
 | 
					          log = output.to_s
 | 
				
			||||||
          log.should contain "[R]"
 | 
					          log.should contain "[C]"
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        it "doesn't write affected code if it is disabled" do
 | 
					        it "doesn't write affected code if it is disabled" do
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,7 @@ module Ameba
 | 
				
			||||||
        source = Source.new "a = 42", "source.cr"
 | 
					        source = Source.new "a = 42", "source.cr"
 | 
				
			||||||
        output = explanation(source)
 | 
					        output = explanation(source)
 | 
				
			||||||
        output.should contain "RULE INFO"
 | 
					        output.should contain "RULE INFO"
 | 
				
			||||||
        output.should contain "Refactoring"
 | 
					        output.should contain "Convention"
 | 
				
			||||||
        output.should contain "Ameba/ErrorRule"
 | 
					        output.should contain "Ameba/ErrorRule"
 | 
				
			||||||
        output.should contain "Always adds an error at 1:1"
 | 
					        output.should contain "Always adds an error at 1:1"
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ module Ameba::Formatter
 | 
				
			||||||
        subject = flycheck
 | 
					        subject = flycheck
 | 
				
			||||||
        subject.source_finished s
 | 
					        subject.source_finished s
 | 
				
			||||||
        subject.output.to_s.should eq(
 | 
					        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
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ module Ameba::Formatter
 | 
				
			||||||
        subject = flycheck
 | 
					        subject = flycheck
 | 
				
			||||||
        subject.source_finished s
 | 
					        subject.source_finished s
 | 
				
			||||||
        subject.output.to_s.should eq(
 | 
					        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
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ module Ameba
 | 
				
			||||||
        s.add_issue DummyRule.new, {1, 2}, "message"
 | 
					        s.add_issue DummyRule.new, {1, 2}, "message"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        result = get_result [s]
 | 
					        result = get_result [s]
 | 
				
			||||||
        result["sources"][0]["issues"][0]["severity"].should eq "Refactoring"
 | 
					        result["sources"][0]["issues"][0]["severity"].should eq "Convention"
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "shows a message" do
 | 
					      it "shows a message" do
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,7 +44,7 @@ module Ameba
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "creates a todo with severity" do
 | 
					      it "creates a todo with severity" do
 | 
				
			||||||
        create_todo.should contain "Refactoring"
 | 
					        create_todo.should contain "Convention"
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "creates a todo with problems count" do
 | 
					      it "creates a todo with problems count" do
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,7 +13,7 @@ module Ameba
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  describe Runner do
 | 
					  describe Runner do
 | 
				
			||||||
    formatter = DummyFormatter.new
 | 
					    formatter = DummyFormatter.new
 | 
				
			||||||
    default_severity = Severity::Refactoring
 | 
					    default_severity = Severity::Convention
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    describe "#run" do
 | 
					    describe "#run" do
 | 
				
			||||||
      it "returns self" do
 | 
					      it "returns self" do
 | 
				
			||||||
| 
						 | 
					@ -148,7 +148,7 @@ module Ameba
 | 
				
			||||||
        s = Source.new %q(WrongConstant = 5)
 | 
					        s = Source.new %q(WrongConstant = 5)
 | 
				
			||||||
        Runner.new(rules, [s], formatter, Severity::Error).run.success?.should be_true
 | 
					        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::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
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "returns false if issue is disabled" do
 | 
					      it "returns false if issue is disabled" do
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,8 +17,8 @@ module Ameba
 | 
				
			||||||
        Severity::Warning.symbol.should eq 'W'
 | 
					        Severity::Warning.symbol.should eq 'W'
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "returns symbol for Refactoring" do
 | 
					      it "returns symbol for Convention" do
 | 
				
			||||||
        Severity::Refactoring.symbol.should eq 'R'
 | 
					        Severity::Convention.symbol.should eq 'C'
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,12 +31,12 @@ module Ameba
 | 
				
			||||||
        Severity.parse("Warning").should eq Severity::Warning
 | 
					        Severity.parse("Warning").should eq Severity::Warning
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "creates refactoring severity by name" do
 | 
					      it "creates convention severity by name" do
 | 
				
			||||||
        Severity.parse("Refactoring").should eq Severity::Refactoring
 | 
					        Severity.parse("Convention").should eq Severity::Convention
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "raises when name is incorrect" do
 | 
					      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")
 | 
					          Severity.parse("BadName")
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
| 
						 | 
					@ -63,14 +63,14 @@ module Ameba
 | 
				
			||||||
        converted.severity.should eq Severity::Warning
 | 
					        converted.severity.should eq Severity::Warning
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "converts from yaml to Severity::Refactoring" do
 | 
					      it "converts from yaml to Severity::Convention" do
 | 
				
			||||||
        yaml = {severity: "refactoring"}.to_yaml
 | 
					        yaml = {severity: "convention"}.to_yaml
 | 
				
			||||||
        converted = SeverityConvertable.from_yaml(yaml)
 | 
					        converted = SeverityConvertable.from_yaml(yaml)
 | 
				
			||||||
        converted.severity.should eq Severity::Refactoring
 | 
					        converted.severity.should eq Severity::Convention
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "raises if severity is not a scalar" do
 | 
					      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
 | 
					        expect_raises(Exception, "Severity must be a scalar") do
 | 
				
			||||||
          SeverityConvertable.from_yaml(yaml)
 | 
					          SeverityConvertable.from_yaml(yaml)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
| 
						 | 
					@ -97,10 +97,10 @@ module Ameba
 | 
				
			||||||
        converted.should eq "---\nseverity: Warning\n"
 | 
					        converted.should eq "---\nseverity: Warning\n"
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      it "converts Severity::Refactoring to yaml" do
 | 
					      it "converts Severity::Convention to yaml" do
 | 
				
			||||||
        yaml = {severity: "refactoring"}.to_yaml
 | 
					        yaml = {severity: "convention"}.to_yaml
 | 
				
			||||||
        converted = SeverityConvertable.from_yaml(yaml).to_yaml
 | 
					        converted = SeverityConvertable.from_yaml(yaml).to_yaml
 | 
				
			||||||
        converted.should eq "---\nseverity: Refactoring\n"
 | 
					        converted.should eq "---\nseverity: Convention\n"
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,7 @@ module Ameba::Cli
 | 
				
			||||||
        opts.config = ""
 | 
					        opts.config = ""
 | 
				
			||||||
      end
 | 
					      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)
 | 
					        opts.fail_level = Severity.parse(level)
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ class Ameba::Config
 | 
				
			||||||
  setter formatter : Formatter::BaseFormatter?
 | 
					  setter formatter : Formatter::BaseFormatter?
 | 
				
			||||||
  setter globs : Array(String)?
 | 
					  setter globs : Array(String)?
 | 
				
			||||||
  getter rules : Array(Rule::Base)
 | 
					  getter rules : Array(Rule::Base)
 | 
				
			||||||
  property severity = Severity::Refactoring
 | 
					  property severity = Severity::Convention
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @rule_groups : Hash(String, Array(Rule::Base))
 | 
					  @rule_groups : Hash(String, Array(Rule::Base))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,7 +229,7 @@ class Ameba::Config
 | 
				
			||||||
      {% end %}
 | 
					      {% end %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      {% if properties["severity".id] == nil %}
 | 
					      {% 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} %}
 | 
					        {% properties["severity".id] = {key: "Severity", default: default, type: Severity, converter: SeverityYamlConverter} %}
 | 
				
			||||||
      {% end %}
 | 
					      {% end %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ module Ameba::Formatter
 | 
				
			||||||
  #           },
 | 
					  #           },
 | 
				
			||||||
  #           "message":   "Useless assignment to variable `a`",
 | 
					  #           "message":   "Useless assignment to variable `a`",
 | 
				
			||||||
  #           "rule_name": "UselessAssign",
 | 
					  #           "rule_name": "UselessAssign",
 | 
				
			||||||
  #           "severity":  "Refactoring",
 | 
					  #           "severity":  "Convention",
 | 
				
			||||||
  #         },
 | 
					  #         },
 | 
				
			||||||
  #         {
 | 
					  #         {
 | 
				
			||||||
  #           "location": {
 | 
					  #           "location": {
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,7 @@ module Ameba::Formatter
 | 
				
			||||||
  #           },
 | 
					  #           },
 | 
				
			||||||
  #           "message":   "Useless assignment to variable `a`",
 | 
					  #           "message":   "Useless assignment to variable `a`",
 | 
				
			||||||
  #           "rule_name": "UselessAssign",
 | 
					  #           "rule_name": "UselessAssign",
 | 
				
			||||||
  #           "severity":  "Refactoring",
 | 
					  #           "severity":  "Convention",
 | 
				
			||||||
  #         },
 | 
					  #         },
 | 
				
			||||||
  #       ],
 | 
					  #       ],
 | 
				
			||||||
  #       "path": "src/ameba/formatter/json_formatter.cr",
 | 
					  #       "path": "src/ameba/formatter/json_formatter.cr",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@ module Ameba
 | 
				
			||||||
  enum Severity
 | 
					  enum Severity
 | 
				
			||||||
    Error
 | 
					    Error
 | 
				
			||||||
    Warning
 | 
					    Warning
 | 
				
			||||||
    Refactoring
 | 
					    Convention
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Returns a symbol uniquely indicating severity.
 | 
					    # Returns a symbol uniquely indicating severity.
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
| 
						 | 
					@ -16,8 +16,8 @@ module Ameba
 | 
				
			||||||
    # Creates Severity by the name.
 | 
					    # Creates Severity by the name.
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    # ```
 | 
					    # ```
 | 
				
			||||||
    # Severity.parse("refactoring") # => Severity::Refactoring
 | 
					    # Severity.parse("convention") # => Severity::Convention
 | 
				
			||||||
    # Severity.parse("foo-bar")     # => Exception: Incorrect severity name
 | 
					    # Severity.parse("foo-bar")    # => Exception: Incorrect severity name
 | 
				
			||||||
    # ```
 | 
					    # ```
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    def self.parse(name : String)
 | 
					    def self.parse(name : String)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue