mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Style improvements
This commit is contained in:
		
							parent
							
								
									628077066e
								
							
						
					
					
						commit
						996dc962db
					
				
					 8 changed files with 10 additions and 7 deletions
				
			
		| 
						 | 
					@ -11,6 +11,7 @@ module Ameba::Rules
 | 
				
			||||||
  # This is because these expressions evaluate to `true` or `false`, so you
 | 
					  # This is because these expressions evaluate to `true` or `false`, so you
 | 
				
			||||||
  # could get the same result by using either the variable directly,
 | 
					  # could get the same result by using either the variable directly,
 | 
				
			||||||
  # or negating the variable.
 | 
					  # or negating the variable.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  struct ComparisonToBoolean < Rule
 | 
					  struct ComparisonToBoolean < Rule
 | 
				
			||||||
    def test(source)
 | 
					    def test(source)
 | 
				
			||||||
      AST::CallVisitor.new self, source
 | 
					      AST::CallVisitor.new self, source
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,7 @@ module Ameba::Rules
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
  # This is because we don't want debugger breakpoints accidentally being
 | 
					  # This is because we don't want debugger breakpoints accidentally being
 | 
				
			||||||
  # committed into our codebase.
 | 
					  # committed into our codebase.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  struct DebuggerStatement < Rule
 | 
					  struct DebuggerStatement < Rule
 | 
				
			||||||
    def test(source)
 | 
					    def test(source)
 | 
				
			||||||
      AST::CallVisitor.new self, source
 | 
					      AST::CallVisitor.new self, source
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
module Ameba::Rules
 | 
					module Ameba::Rules
 | 
				
			||||||
  # A rule that disallows lines longer than 79 symbols.
 | 
					  # A rule that disallows lines longer than 79 symbols.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  struct LineLength < Rule
 | 
					  struct LineLength < Rule
 | 
				
			||||||
    def test(source)
 | 
					    def test(source)
 | 
				
			||||||
      source.lines.each_with_index do |line, index|
 | 
					      source.lines.each_with_index do |line, index|
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,7 @@ module Ameba::Rules
 | 
				
			||||||
  #   :ok
 | 
					  #   :ok
 | 
				
			||||||
  # end
 | 
					  # end
 | 
				
			||||||
  # ```
 | 
					  # ```
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  struct LiteralInCondition < Rule
 | 
					  struct LiteralInCondition < Rule
 | 
				
			||||||
    include AST::Util
 | 
					    include AST::Util
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ module Ameba::Rules
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
  # ```
 | 
					  # ```
 | 
				
			||||||
  # "Hello, #{:Ary}"
 | 
					  # "Hello, #{:Ary}"
 | 
				
			||||||
  # "The are #{4} cats"
 | 
					  # "There are #{4} cats"
 | 
				
			||||||
  # ```
 | 
					  # ```
 | 
				
			||||||
  #
 | 
					  #
 | 
				
			||||||
  struct LiteralInInterpolation < Rule
 | 
					  struct LiteralInInterpolation < Rule
 | 
				
			||||||
| 
						 | 
					@ -17,12 +17,8 @@ module Ameba::Rules
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::StringInterpolation)
 | 
					    def test(source, node : Crystal::StringInterpolation)
 | 
				
			||||||
      has_literal = node.expressions.any? do |e|
 | 
					      found = node.expressions.any? { |e| !string_literal?(e) && literal?(e) }
 | 
				
			||||||
        !string_literal?(e) && literal?(e)
 | 
					      return unless found
 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      return unless has_literal
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      source.error self, node.location.try &.line_number,
 | 
					      source.error self, node.location.try &.line_number,
 | 
				
			||||||
        "Literal value found in interpolation"
 | 
					        "Literal value found in interpolation"
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
module Ameba::Rules
 | 
					module Ameba::Rules
 | 
				
			||||||
  # A rule that disallows trailing blank lines at the end of the source file.
 | 
					  # A rule that disallows trailing blank lines at the end of the source file.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  struct TrailingBlankLines < Rule
 | 
					  struct TrailingBlankLines < Rule
 | 
				
			||||||
    def test(source)
 | 
					    def test(source)
 | 
				
			||||||
      if source.lines.size > 1 && source.lines[-2, 2].join.strip.empty?
 | 
					      if source.lines.size > 1 && source.lines[-2, 2].join.strip.empty?
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
module Ameba::Rules
 | 
					module Ameba::Rules
 | 
				
			||||||
  # A rule that disallows trailing whitespaces.
 | 
					  # A rule that disallows trailing whitespaces.
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  struct TrailingWhitespace < Rule
 | 
					  struct TrailingWhitespace < Rule
 | 
				
			||||||
    def test(source)
 | 
					    def test(source)
 | 
				
			||||||
      source.lines.each_with_index do |line, index|
 | 
					      source.lines.each_with_index do |line, index|
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@ module Ameba::Rules
 | 
				
			||||||
  #   :one
 | 
					  #   :one
 | 
				
			||||||
  # end
 | 
					  # end
 | 
				
			||||||
  # ```
 | 
					  # ```
 | 
				
			||||||
 | 
					  #
 | 
				
			||||||
  struct UnlessElse < Rule
 | 
					  struct UnlessElse < Rule
 | 
				
			||||||
    def test(source)
 | 
					    def test(source)
 | 
				
			||||||
      AST::UnlessVisitor.new self, source
 | 
					      AST::UnlessVisitor.new self, source
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue