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
 | 
			
		||||
  # could get the same result by using either the variable directly,
 | 
			
		||||
  # or negating the variable.
 | 
			
		||||
  #
 | 
			
		||||
  struct ComparisonToBoolean < Rule
 | 
			
		||||
    def test(source)
 | 
			
		||||
      AST::CallVisitor.new self, source
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ module Ameba::Rules
 | 
			
		|||
  #
 | 
			
		||||
  # This is because we don't want debugger breakpoints accidentally being
 | 
			
		||||
  # committed into our codebase.
 | 
			
		||||
  #
 | 
			
		||||
  struct DebuggerStatement < Rule
 | 
			
		||||
    def test(source)
 | 
			
		||||
      AST::CallVisitor.new self, source
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
module Ameba::Rules
 | 
			
		||||
  # A rule that disallows lines longer than 79 symbols.
 | 
			
		||||
  #
 | 
			
		||||
  struct LineLength < Rule
 | 
			
		||||
    def test(source)
 | 
			
		||||
      source.lines.each_with_index do |line, index|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@ module Ameba::Rules
 | 
			
		|||
  #   :ok
 | 
			
		||||
  # end
 | 
			
		||||
  # ```
 | 
			
		||||
  #
 | 
			
		||||
  struct LiteralInCondition < Rule
 | 
			
		||||
    include AST::Util
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ module Ameba::Rules
 | 
			
		|||
  #
 | 
			
		||||
  # ```
 | 
			
		||||
  # "Hello, #{:Ary}"
 | 
			
		||||
  # "The are #{4} cats"
 | 
			
		||||
  # "There are #{4} cats"
 | 
			
		||||
  # ```
 | 
			
		||||
  #
 | 
			
		||||
  struct LiteralInInterpolation < Rule
 | 
			
		||||
| 
						 | 
				
			
			@ -17,12 +17,8 @@ module Ameba::Rules
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    def test(source, node : Crystal::StringInterpolation)
 | 
			
		||||
      has_literal = node.expressions.any? do |e|
 | 
			
		||||
        !string_literal?(e) && literal?(e)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      return unless has_literal
 | 
			
		||||
 | 
			
		||||
      found = node.expressions.any? { |e| !string_literal?(e) && literal?(e) }
 | 
			
		||||
      return unless found
 | 
			
		||||
      source.error self, node.location.try &.line_number,
 | 
			
		||||
        "Literal value found in interpolation"
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
module Ameba::Rules
 | 
			
		||||
  # A rule that disallows trailing blank lines at the end of the source file.
 | 
			
		||||
  #
 | 
			
		||||
  struct TrailingBlankLines < Rule
 | 
			
		||||
    def test(source)
 | 
			
		||||
      if source.lines.size > 1 && source.lines[-2, 2].join.strip.empty?
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
module Ameba::Rules
 | 
			
		||||
  # A rule that disallows trailing whitespaces.
 | 
			
		||||
  #
 | 
			
		||||
  struct TrailingWhitespace < Rule
 | 
			
		||||
    def test(source)
 | 
			
		||||
      source.lines.each_with_index do |line, index|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,6 +35,7 @@ module Ameba::Rules
 | 
			
		|||
  #   :one
 | 
			
		||||
  # end
 | 
			
		||||
  # ```
 | 
			
		||||
  #
 | 
			
		||||
  struct UnlessElse < Rule
 | 
			
		||||
    def test(source)
 | 
			
		||||
      AST::UnlessVisitor.new self, source
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue