mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Correct location name of reported issue
This commit is contained in:
		
							parent
							
								
									9fa13848bf
								
							
						
					
					
						commit
						799c0fd5e1
					
				
					 2 changed files with 4 additions and 7 deletions
				
			
		| 
						 | 
					@ -51,16 +51,14 @@ module Ameba::Rule::Performance
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it "reports rule, pos and message" do
 | 
					    it "reports rule, pos and message" do
 | 
				
			||||||
      s = Source.new %(
 | 
					      s = Source.new %(
 | 
				
			||||||
        File.read(path)
 | 
					        lines.split("\n").reject(&.empty?).size
 | 
				
			||||||
          .split("\n")
 | 
					 | 
				
			||||||
          .reject(&.empty?)
 | 
					 | 
				
			||||||
          .size
 | 
					 | 
				
			||||||
      ), "source.cr"
 | 
					      ), "source.cr"
 | 
				
			||||||
      subject.catch(s).should_not be_valid
 | 
					      subject.catch(s).should_not be_valid
 | 
				
			||||||
      issue = s.issues.first
 | 
					      issue = s.issues.first
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      issue.rule.should_not be_nil
 | 
					      issue.rule.should_not be_nil
 | 
				
			||||||
      issue.location.to_s.should eq "source.cr:2:9"
 | 
					      issue.location.to_s.should eq "source.cr:2:4"
 | 
				
			||||||
 | 
					      issue.end_location.to_s.should eq "source.cr:2:25"
 | 
				
			||||||
      issue.message.should eq "Use `count {...}` instead of `reject {...}.size`."
 | 
					      issue.message.should eq "Use `count {...}` instead of `reject {...}.size`."
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,6 @@ module Ameba::Rule::Performance
 | 
				
			||||||
                   caller names (`select`/`reject` by default)."
 | 
					                   caller names (`select`/`reject` by default)."
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source)
 | 
					    def test(source)
 | 
				
			||||||
      AST::NodeVisitor.new self, source
 | 
					      AST::NodeVisitor.new self, source
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					@ -43,7 +42,7 @@ module Ameba::Rule::Performance
 | 
				
			||||||
      if obj.is_a?(Crystal::Call) &&
 | 
					      if obj.is_a?(Crystal::Call) &&
 | 
				
			||||||
         object_call_names.includes?(obj.name) && !obj.block.nil?
 | 
					         object_call_names.includes?(obj.name) && !obj.block.nil?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        issue_for obj, MSG % obj.name
 | 
					        issue_for obj.name_location, node.name_end_location, MSG % obj.name
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue