turboladen/tailor

View on GitHub

Showing 72 of 72 total issues

Class Lexer has 53 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Lexer < Ripper::Lexer
    include CompositeObservable
    include LexerConstants
    include LogSwitch::Mixin

Severity: Major
Found in lib/tailor/lexer.rb - About 7 hrs to fix

    Method parse! has 169 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.parse!(args)
            register_custom_option_types
            options = OpenStruct.new
            options.config_file = ''
            options.output_file = ''
    Severity: Major
    Found in lib/tailor/cli/options.rb - About 6 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      class Tailor
        module Rulers
      
          # Checks for spaces before a +)+ as given by +@config+.  It skips checking
          # when:
      Severity: Major
      Found in lib/tailor/rulers/spaces_before_rparen_ruler.rb and 1 other location - About 3 hrs to fix
      lib/tailor/rulers/spaces_before_rbracket_ruler.rb on lines 3..73

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 130.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      class Tailor
        module Rulers
      
          # Checks for spaces before a +]+ as given by +@config+.  It skips checking
          # when:
      Severity: Major
      Found in lib/tailor/rulers/spaces_before_rbracket_ruler.rb and 1 other location - About 3 hrs to fix
      lib/tailor/rulers/spaces_before_rparen_ruler.rb on lines 3..73

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 130.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      File lexer.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'ripper'
      require_relative 'composite_observable'
      require_relative 'lexed_line'
      require_relative 'lexer/lexer_constants'
      require_relative 'logger'
      Severity: Minor
      Found in lib/tailor/lexer.rb - About 3 hrs to fix

        Method define_observer has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.define_observer(name)
              define_method("add_#{name}_observer") do |observer|
                @notifiers = {} unless defined? @notifiers
                @notifiers[name] = {} unless @notifiers[name]
        
        
        Severity: Minor
        Found in lib/tailor/composite_observable.rb - About 3 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method check_spaces_after_comma has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

              def check_spaces_after_comma(lexed_line, lineno)
                log "Commas found at: #{@comma_columns}" unless @comma_columns.empty?
        
                @comma_columns.each do |c|
                  event_index = lexed_line.event_index(c)
        Severity: Minor
        Found in lib/tailor/rulers/spaces_after_comma_ruler.rb - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Class IndentationSpacesRuler has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class IndentationSpacesRuler < Tailor::Ruler
              def initialize(config, options)
                super(config, options)
                add_lexer_observers(
                  :comment,
        Severity: Minor
        Found in lib/tailor/rulers/indentation_spaces_ruler.rb - About 2 hrs to fix

          Class LexedLine has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class LexedLine < Array
              include LexerConstants
          
              def initialize(lexed_file, lineno)
                @lineno = lineno
          Severity: Minor
          Found in lib/tailor/lexed_line.rb - About 2 hrs to fix

            Class IndentationManager has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class IndentationManager
                    include Tailor::LexerConstants
                    include Tailor::Logger::Mixin
            
                    # These are event names generated by the {Lexer} that signify
            Severity: Minor
            Found in lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb - About 2 hrs to fix

              Method build_xml has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                      def build_xml(node, doc = nil, xml_node=nil)
                        doc, xml_node = xml_document(doc, xml_node)
              
                        if node.respond_to?(:each)
                          # First child is the node name
              Severity: Minor
              Found in lib/tailor/rulers/indentation_spaces_ruler/ast_xml.rb - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Method count_spaces has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def count_spaces(lexed_line, column)
                      event_index = lexed_line.event_index(column)
              
                      if event_index.nil?
                        log 'No lbracket in this line.  Moving on...'
              Severity: Minor
              Found in lib/tailor/rulers/spaces_after_lbracket_ruler.rb - About 1 hr to fix

                Method count_spaces has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def count_spaces(lexed_line, column)
                        event_index = lexed_line.event_index(column)
                
                        if event_index.nil?
                          log 'No lparen in this line.  Moving on...'
                Severity: Minor
                Found in lib/tailor/rulers/spaces_after_lparen_ruler.rb - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        def ignored_nl_update(lexed_line, _, _)
                          return if @method_start_lines.empty?
                          return if lexed_line.only_spaces?
                          return if lexed_line.comment_line?
                  
                  
                  Severity: Major
                  Found in lib/tailor/rulers/max_code_lines_in_method_ruler.rb and 1 other location - About 1 hr to fix
                  lib/tailor/rulers/max_code_lines_in_class_ruler.rb on lines 17..32

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 56.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        def ignored_nl_update(lexed_line, _, _)
                          return if @class_start_lines.empty?
                          return if lexed_line.only_spaces?
                          return if lexed_line.comment_line?
                  
                  
                  Severity: Major
                  Found in lib/tailor/rulers/max_code_lines_in_class_ruler.rb and 1 other location - About 1 hr to fix
                  lib/tailor/rulers/max_code_lines_in_method_ruler.rb on lines 17..32

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 56.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Method modifier_keyword? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def modifier_keyword?
                          return false unless keyword_to_indent?
                  
                          line_of_text = @options[:full_line_of_text]
                          log "Line of text: #{line_of_text}"
                  Severity: Minor
                  Found in lib/tailor/lexer/token.rb - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method count_spaces has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def count_spaces(lexed_line, column)
                          current_index = lexed_line.event_index(column)
                          log "Current event index: #{current_index}"
                          previous_event = lexed_line.at(current_index - 1)
                          log "Previous event: #{previous_event}"
                  Severity: Minor
                  Found in lib/tailor/rulers/spaces_before_lbrace_ruler.rb - About 1 hr to fix

                    Method modifier_keyword? has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def modifier_keyword?
                            return false unless keyword_to_indent?
                    
                            line_of_text = @options[:full_line_of_text]
                            log "Line of text: #{line_of_text}"
                    Severity: Minor
                    Found in lib/tailor/lexer/token.rb - About 1 hr to fix

                      Method check_spaces_after_comma has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def check_spaces_after_comma(lexed_line, lineno)
                              log "Commas found at: #{@comma_columns}" unless @comma_columns.empty?
                      
                              @comma_columns.each do |c|
                                event_index = lexed_line.event_index(c)
                      Severity: Minor
                      Found in lib/tailor/rulers/spaces_after_comma_ruler.rb - About 1 hr to fix

                        Method count_spaces has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def count_spaces(lexed_line, column)
                                event_index = lexed_line.event_index(column)
                        
                                if event_index.nil?
                                  log 'No lbrace in this line.  Moving on...'
                        Severity: Minor
                        Found in lib/tailor/rulers/spaces_after_lbrace_ruler.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language