mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	fix(lint): Lint/UnusedBlockArgument is triggered by abstract def
closes #352
This commit is contained in:
		
							parent
							
								
									a80672730c
								
							
						
					
					
						commit
						17e9566c7e
					
				
					 2 changed files with 9 additions and 0 deletions
				
			
		| 
						 | 
					@ -89,6 +89,13 @@ module Ameba::Rule::Lint
 | 
				
			||||||
        CRYSTAL
 | 
					        CRYSTAL
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it "doesn't report if used in abstract def" do
 | 
				
			||||||
 | 
					      expect_no_issues subject, <<-CRYSTAL
 | 
				
			||||||
 | 
					        abstract def debug(id : String, &on_message: Callback)
 | 
				
			||||||
 | 
					        abstract def info(&on_message: Callback)
 | 
				
			||||||
 | 
					        CRYSTAL
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    context "super" do
 | 
					    context "super" do
 | 
				
			||||||
      it "reports if variable is not referenced implicitly by super" do
 | 
					      it "reports if variable is not referenced implicitly by super" do
 | 
				
			||||||
        source = expect_issue subject, <<-CRYSTAL
 | 
					        source = expect_issue subject, <<-CRYSTAL
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,6 +47,8 @@ module Ameba::Rule::Lint
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::Def, scope : AST::Scope)
 | 
					    def test(source, node : Crystal::Def, scope : AST::Scope)
 | 
				
			||||||
 | 
					      return if node.abstract?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      return unless block_arg = node.block_arg
 | 
					      return unless block_arg = node.block_arg
 | 
				
			||||||
      return unless block_arg = scope.arguments.find(&.node.== block_arg)
 | 
					      return unless block_arg = scope.arguments.find(&.node.== block_arg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue