mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Merge pull request #337 from crystal-ameba/Sija/tweak-reported-locations
Tweak reported rule locations
This commit is contained in:
		
						commit
						d5fbb07c3a
					
				
					 3 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -38,7 +38,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
    it "reports if block arg is not used" do
 | 
					    it "reports if block arg is not used" do
 | 
				
			||||||
      source = expect_issue subject, <<-CRYSTAL
 | 
					      source = expect_issue subject, <<-CRYSTAL
 | 
				
			||||||
        def method(a, b, c, &block)
 | 
					        def method(a, b, c, &block)
 | 
				
			||||||
                           # ^ error: Unused block argument `block`. [...]
 | 
					                           # ^^^^^ error: Unused block argument `block`. [...]
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
        CRYSTAL
 | 
					        CRYSTAL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
    it "reports if unused and there is yield" do
 | 
					    it "reports if unused and there is yield" do
 | 
				
			||||||
      source = expect_issue subject, <<-CRYSTAL
 | 
					      source = expect_issue subject, <<-CRYSTAL
 | 
				
			||||||
        def method(a, b, c, &block)
 | 
					        def method(a, b, c, &block)
 | 
				
			||||||
                           # ^ error: Use `&` as an argument name to indicate that it won't be referenced.
 | 
					                           # ^^^^^ error: Use `&` as an argument name to indicate that it won't be referenced.
 | 
				
			||||||
          3.times do |i|
 | 
					          3.times do |i|
 | 
				
			||||||
            i.try do
 | 
					            i.try do
 | 
				
			||||||
              yield i
 | 
					              yield i
 | 
				
			||||||
| 
						 | 
					@ -94,7 +94,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
        source = expect_issue subject, <<-CRYSTAL
 | 
					        source = expect_issue subject, <<-CRYSTAL
 | 
				
			||||||
          class Bar < Foo
 | 
					          class Bar < Foo
 | 
				
			||||||
            def method(a, b, c, &block)
 | 
					            def method(a, b, c, &block)
 | 
				
			||||||
                               # ^ error: Unused block argument `block`. [...]
 | 
					                               # ^^^^^ error: Unused block argument `block`. [...]
 | 
				
			||||||
              super a, b, c
 | 
					              super a, b, c
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if scope.yields?
 | 
					      if scope.yields?
 | 
				
			||||||
        if location && end_location
 | 
					        if location && end_location
 | 
				
			||||||
          issue_for block_arg.node, MSG_YIELDED do |corrector|
 | 
					          issue_for location, end_location, MSG_YIELDED do |corrector|
 | 
				
			||||||
            corrector.remove(location, end_location)
 | 
					            corrector.remove(location, end_location)
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
| 
						 | 
					@ -67,7 +67,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
        return if block_arg.ignored?
 | 
					        return if block_arg.ignored?
 | 
				
			||||||
        if location && end_location
 | 
					        if location && end_location
 | 
				
			||||||
          issue_for block_arg.node, MSG_UNUSED % block_arg.name do |corrector|
 | 
					          issue_for location, end_location, MSG_UNUSED % block_arg.name do |corrector|
 | 
				
			||||||
            corrector.insert_before(location, '_')
 | 
					            corrector.insert_before(location, '_')
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,7 @@ module Ameba::Rule::Style
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      issue_for node, MSG do |corrector|
 | 
					      issue_for location, cond_end_location, MSG do |corrector|
 | 
				
			||||||
        keyword_begin_pos = source.pos(location)
 | 
					        keyword_begin_pos = source.pos(location)
 | 
				
			||||||
        keyword_end_pos = keyword_begin_pos + {{ "unless".size }}
 | 
					        keyword_end_pos = keyword_begin_pos + {{ "unless".size }}
 | 
				
			||||||
        keyword_range = keyword_begin_pos...keyword_end_pos
 | 
					        keyword_range = keyword_begin_pos...keyword_end_pos
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue