mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	
							parent
							
								
									98f0aa71e9
								
							
						
					
					
						commit
						dbac46b68a
					
				
					 2 changed files with 14 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -138,6 +138,19 @@ module Ameba::Rule::Lint
 | 
			
		|||
      subject.catch(source).should be_valid
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "doesn't report if it shadows throwaway arguments" do
 | 
			
		||||
      source = Source.new %(
 | 
			
		||||
        data = [{1, "a"}, {2, "b"}, {3, "c"}]
 | 
			
		||||
 | 
			
		||||
        data.each do |_, string|
 | 
			
		||||
          data.each do |number, _|
 | 
			
		||||
            puts string, number
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
      )
 | 
			
		||||
      subject.catch(source).should be_valid
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "reports rule, location and message" do
 | 
			
		||||
      source = Source.new %(
 | 
			
		||||
        foo = 1
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,6 +53,7 @@ module Ameba::Rule::Lint
 | 
			
		|||
 | 
			
		||||
    private def find_shadowing(source, scope)
 | 
			
		||||
      scope.arguments.each do |arg|
 | 
			
		||||
        next if arg.ignored?
 | 
			
		||||
        if scope.outer_scope.try &.find_variable(arg.name)
 | 
			
		||||
          issue_for arg, MSG % arg.name
 | 
			
		||||
        end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue