mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Compress identical method definitions
This commit is contained in:
		
							parent
							
								
									b79f3e6e07
								
							
						
					
					
						commit
						a8f953a2b2
					
				
					 6 changed files with 6 additions and 51 deletions
				
			
		| 
						 | 
					@ -52,11 +52,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
      check_node(source, node, node.block)
 | 
					      check_node(source, node, node.block)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::While)
 | 
					    def test(source, node : Crystal::While | Crystal::Until)
 | 
				
			||||||
      check_node(source, node, node.body) if literal?(node.cond)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::Until)
 | 
					 | 
				
			||||||
      check_node(source, node, node.body) if literal?(node.cond)
 | 
					      check_node(source, node, node.body) if literal?(node.cond)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,15 +33,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
      issue_for node, MSG if static_literal?(node.cond)
 | 
					      issue_for node, MSG if static_literal?(node.cond)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::If)
 | 
					    def test(source, node : Crystal::If | Crystal::Unless | Crystal::Case)
 | 
				
			||||||
      check_node source, node
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::Unless)
 | 
					 | 
				
			||||||
      check_node source, node
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::Case)
 | 
					 | 
				
			||||||
      check_node source, node
 | 
					      check_node source, node
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,11 +45,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
      ]
 | 
					      ]
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::ProcLiteral, scope : AST::Scope)
 | 
					    def test(source, node : Crystal::ProcLiteral | Crystal::Block, scope : AST::Scope)
 | 
				
			||||||
      find_shadowing source, scope
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::Block, scope : AST::Scope)
 | 
					 | 
				
			||||||
      find_shadowing source, scope
 | 
					      find_shadowing source, scope
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,12 +61,7 @@ module Ameba::Rule::Lint
 | 
				
			||||||
        @parent.accept self
 | 
					        @parent.accept self
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      def visit(node : Crystal::If)
 | 
					      def visit(node : Crystal::If | Crystal::Unless)
 | 
				
			||||||
        @rule.check_node(@source, @parent, node.cond)
 | 
					 | 
				
			||||||
        true
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      def visit(node : Crystal::Unless)
 | 
					 | 
				
			||||||
        @rule.check_node(@source, @parent, node.cond)
 | 
					        @rule.check_node(@source, @parent, node.cond)
 | 
				
			||||||
        true
 | 
					        true
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,23 +66,7 @@ module Ameba::Rule::Style
 | 
				
			||||||
      issue_for node, MSG % {expected, name}
 | 
					      issue_for node, MSG % {expected, name}
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::ClassDef)
 | 
					    def test(source, node : Crystal::Alias | Crystal::ClassDef | Crystal::ModuleDef | Crystal::LibDef | Crystal::EnumDef)
 | 
				
			||||||
      check_node(source, node)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::Alias)
 | 
					 | 
				
			||||||
      check_node(source, node)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::LibDef)
 | 
					 | 
				
			||||||
      check_node(source, node)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::EnumDef)
 | 
					 | 
				
			||||||
      check_node(source, node)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::ModuleDef)
 | 
					 | 
				
			||||||
      check_node(source, node)
 | 
					      check_node(source, node)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,15 +39,7 @@ module Ameba::Rule::Style
 | 
				
			||||||
      VarVisitor.new self, source
 | 
					      VarVisitor.new self, source
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::Var)
 | 
					    def test(source, node : Crystal::Var | Crystal::InstanceVar | Crystal::ClassVar)
 | 
				
			||||||
      check_node source, node
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::InstanceVar)
 | 
					 | 
				
			||||||
      check_node source, node
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def test(source, node : Crystal::ClassVar)
 | 
					 | 
				
			||||||
      check_node source, node
 | 
					      check_node source, node
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue