mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Remove extraneous blank lines
This commit is contained in:
		
							parent
							
								
									af5d825015
								
							
						
					
					
						commit
						928a260d51
					
				
					 12 changed files with 0 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -44,7 +44,6 @@ module Ameba::AST
 | 
			
		|||
    #   end
 | 
			
		||||
    # end
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def in_loop?
 | 
			
		||||
      @parent.loop?
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,7 +28,6 @@ module Ameba::AST
 | 
			
		|||
    # ```
 | 
			
		||||
    # Assignment.new(node, variable, scope)
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(@node, @variable, @scope)
 | 
			
		||||
      if scope = @variable.scope
 | 
			
		||||
        @branch = Branch.of(@node, scope)
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +94,6 @@ module Ameba::AST
 | 
			
		|||
    #   puts(b)
 | 
			
		||||
    # end
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def transformed?
 | 
			
		||||
      return false unless (assign = node).is_a?(Crystal::Assign)
 | 
			
		||||
      return false unless (value = assign.value).is_a?(Crystal::Call)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,6 @@ module Ameba::AST
 | 
			
		|||
    # ```
 | 
			
		||||
    # Variable.new(node, scope)
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(@node, @scope)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +44,6 @@ module Ameba::AST
 | 
			
		|||
    # variable.assign(node2)
 | 
			
		||||
    # variable.assignment.size # => 2
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def assign(node, scope)
 | 
			
		||||
      assignments << Assignment.new(node, self, scope)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,7 +67,6 @@ module Ameba::AST
 | 
			
		|||
    # variable = Variable.new(node, scope)
 | 
			
		||||
    # variable.reference(var_node, some_scope)
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def reference(node : Crystal::Var, scope : Scope)
 | 
			
		||||
      Reference.new(node, scope).tap do |reference|
 | 
			
		||||
        references << reference
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,6 @@ module Ameba::AST
 | 
			
		|||
    # ```
 | 
			
		||||
    # visitor = Ameba::AST::NodeVisitor.new(rule, source)
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(@rule, @source)
 | 
			
		||||
      @source.ast.accept self
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ module Ameba::Formatter
 | 
			
		|||
    # ExplainFormatter.new output,
 | 
			
		||||
    #   {file: path, line: line_number, column: column_number}
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(@output, loc)
 | 
			
		||||
      @location = Crystal::Location.new(loc[:file], loc[:line], loc[:column])
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,6 @@ module Ameba
 | 
			
		|||
    # ```
 | 
			
		||||
    # find_files_by_globs(["**/*.cr", "!lib"])
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def find_files_by_globs(globs)
 | 
			
		||||
      rejected = rejected_globs(globs)
 | 
			
		||||
      selected = globs - rejected
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +19,6 @@ module Ameba
 | 
			
		|||
    # ```
 | 
			
		||||
    # expand(["spec/*.cr", "src"]) # => all files in src folder + first level specs
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def expand(globs)
 | 
			
		||||
      globs.flat_map do |glob|
 | 
			
		||||
        glob += "/**/*.cr" if File.directory?(glob)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,7 +36,6 @@ module Ameba
 | 
			
		|||
    #   Time.epoch(1483859302)
 | 
			
		||||
    # end
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def location_disabled?(location, rule)
 | 
			
		||||
      return false if rule.name.in?(Rule::SPECIAL)
 | 
			
		||||
      return false unless line_number = location.try &.line_number.try &.- 1
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +64,6 @@ module Ameba
 | 
			
		|||
    # line = "# # ameba:disable Rule1, Rule2"
 | 
			
		||||
    # parse_inline_directive(line) # => nil
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def parse_inline_directive(line)
 | 
			
		||||
      if directive = COMMENT_DIRECTIVE_REGEX.match(line)
 | 
			
		||||
        return if commented_out?(line.gsub(directive[0], ""))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,7 +50,6 @@ module Ameba::Rule
 | 
			
		|||
    # source = MyRule.new.catch(source)
 | 
			
		||||
    # source.valid?
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def catch(source : Source)
 | 
			
		||||
      source.tap { |s| test s }
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +64,6 @@ module Ameba::Rule
 | 
			
		|||
    #
 | 
			
		||||
    # MyRule.new.name # => "MyRule"
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def name
 | 
			
		||||
      {{@type}}.rule_name
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +77,6 @@ module Ameba::Rule
 | 
			
		|||
    #
 | 
			
		||||
    # MyGroup::MyRule.new.group # => "MyGroup"
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def group
 | 
			
		||||
      {{@type}}.group_name
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +88,6 @@ module Ameba::Rule
 | 
			
		|||
    # ```
 | 
			
		||||
    # my_rule.excluded?(source) # => true or false
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def excluded?(source)
 | 
			
		||||
      excluded.try &.any? do |path|
 | 
			
		||||
        source.matches_path?(path) ||
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +101,6 @@ module Ameba::Rule
 | 
			
		|||
    # ```
 | 
			
		||||
    # my_rule.special? # => true or false
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def special?
 | 
			
		||||
      name.in?(SPECIAL)
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,6 @@ module Ameba
 | 
			
		|||
    #
 | 
			
		||||
    # Ameba::Runner.new config
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(config : Config)
 | 
			
		||||
      @sources = config.sources
 | 
			
		||||
      @formatter = config.formatter
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +63,6 @@ module Ameba
 | 
			
		|||
    # runner = Ameba::Runner.new config
 | 
			
		||||
    # runner.run # => returns runner again
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def run
 | 
			
		||||
      @formatter.started @sources
 | 
			
		||||
      channels = @sources.map { Channel(Exception?).new }
 | 
			
		||||
| 
						 | 
				
			
			@ -112,7 +110,6 @@ module Ameba
 | 
			
		|||
    # runner.run
 | 
			
		||||
    # runner.explain({file: file, line: l, column: c})
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def explain(location, output = STDOUT)
 | 
			
		||||
      Formatter::ExplainFormatter.new(output, location).finished @sources
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +122,6 @@ module Ameba
 | 
			
		|||
    # runner.run
 | 
			
		||||
    # runner.success? # => true or false
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def success?
 | 
			
		||||
      @sources.all? do |source|
 | 
			
		||||
        source.issues
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,6 @@ module Ameba
 | 
			
		|||
    # Severity.parse("convention") # => Severity::Convention
 | 
			
		||||
    # Severity.parse("foo-bar")    # => Exception: Incorrect severity name
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def self.parse(name : String)
 | 
			
		||||
      super name
 | 
			
		||||
    rescue ArgumentError
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,6 @@ module Ameba
 | 
			
		|||
    # path = "./src/source.cr"
 | 
			
		||||
    # Ameba::Source.new File.read(path), path
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(@code, @path = "")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,6 @@ module Ameba
 | 
			
		|||
    # source = Ameba::Source.new code, path
 | 
			
		||||
    # Ameba::Tokenizer.new(source)
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(source)
 | 
			
		||||
      @lexer = Crystal::Lexer.new source.code
 | 
			
		||||
      @lexer.count_whitespace = true
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +32,6 @@ module Ameba
 | 
			
		|||
    # lexer = Crystal::Lexer.new(code)
 | 
			
		||||
    # Ameba::Tokenizer.new(lexer)
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(@lexer : Crystal::Lexer)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +42,6 @@ module Ameba
 | 
			
		|||
    #   puts token
 | 
			
		||||
    # end
 | 
			
		||||
    # ```
 | 
			
		||||
    #
 | 
			
		||||
    def run(&block : Crystal::Token -> _)
 | 
			
		||||
      run_normal_state @lexer, &block
 | 
			
		||||
      true
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue