louismullie/treat

View on GitHub

Showing 128 of 128 total issues

Avoid deeply nested control flow statements.
Open

            v = v.to_i if v =~ /^[0-9]*$/
Severity: Major
Found in lib/treat/workers/formatters/unserializers/xml.rb - About 45 mins to fix

    Method set_group_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_group_options(group, conf)
        group.module_eval do
          extend Treat::Workers::Groupable
          self.type = conf.type
          self.targets = conf.targets
    Severity: Minor
    Found in lib/treat/workers/categorizable.rb - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

                v = v[1..-1].intern if v[0] == ':'
    Severity: Major
    Found in lib/treat/workers/formatters/unserializers/xml.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  v = v.to_f if v =~ /^[0-9\.]*$/
      Severity: Major
      Found in lib/treat/workers/formatters/unserializers/xml.rb - About 45 mins to fix

        Method call_worker has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def call_worker(entity, task, worker, group, options)
        
            if worker.nil? || worker == :default
              worker = find_worker(entity, group)
            end
        Severity: Minor
        Found in lib/treat/entities/entity/delegatable.rb - About 45 mins 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 conjugate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.conjugate(entity, options = {})
            
            options = DefaultOptions.merge(options)
            cat = entity.check_has(:category)
            return if cat != 'verb' && options[:strict]
        Severity: Minor
        Found in lib/treat/workers/inflectors/conjugators/linguistics.rb - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                    v = false if v == 'false'
        Severity: Major
        Found in lib/treat/workers/formatters/unserializers/xml.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      elsif value.is_a?(Hash)
                        label << "\\n#{feature}: \\n\{ "
                        value.each do |k,v|
                          v = v ? v.inspect : ' -- '
                          v = escape(v)
          Severity: Major
          Found in lib/treat/workers/formatters/visualizers/dot.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            v = "*#{v.id}" if v.is_a?(Treat::Entities::Entity)
            Severity: Major
            Found in lib/treat/workers/formatters/visualizers/dot.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            label = label[0..-4] unless label[-2] == '{'
              Severity: Major
              Found in lib/treat/workers/formatters/visualizers/dot.rb - About 45 mins to fix

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

                    def singular(word)
                      return "" if word == ""
                      if result = singular_of[word]
                        return result.dup
                      end
                Severity: Minor
                Found in lib/treat/workers/inflectors/declensors/english/inflect.rb and 1 other location - About 45 mins to fix
                lib/treat/workers/inflectors/declensors/english/inflect.rb on lines 152..163

                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 39.

                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 plural(word)
                      return "" if word == ""
                      if result = plural_of[word]
                        return result.dup
                      end
                Severity: Minor
                Found in lib/treat/workers/inflectors/declensors/english/inflect.rb and 1 other location - About 45 mins to fix
                lib/treat/workers/inflectors/declensors/english/inflect.rb on lines 126..136

                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 39.

                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 print_debug has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def print_debug(entity, task, worker, group, options)
                Severity: Minor
                Found in lib/treat/entities/entity/debuggable.rb - About 35 mins to fix

                  Method call_worker has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def call_worker(entity, task, worker, group, options)
                  Severity: Minor
                  Found in lib/treat/entities/entity/delegatable.rb - About 35 mins to fix

                    Method each_entity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def each_entity(*types)
                        types = [:entity] if types.size == 0
                        f = false
                        types.each do |t2|
                          if is_a?(Treat::Entities.const_get(t2.cc))
                    Severity: Minor
                    Found in lib/treat/entities/entity/iterable.rb - About 35 mins 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 method_missing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def method_missing(sym, *args, &block)
                          if [:do, :apply].include?(sym) || 
                            Treat::Workers.lookup(sym)
                            map do |el|
                              if el.is_a?(Treat::Entities::Entity)
                    Severity: Minor
                    Found in lib/treat/proxies/array.rb - About 35 mins 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 register has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def register(entity)
                        unless @registry 
                          @count, @registry = 0, 
                          {id: {}, value: {}, position:{}, type: {}} 
                        end
                    Severity: Minor
                    Found in lib/treat/entities/entity/registrable.rb - About 35 mins 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 set_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.set_options(lang, options)
                        
                        return @@segmenters[lang] if @@segmenters[lang]
                        
                        if options[:model]
                    Severity: Minor
                    Found in lib/treat/workers/processors/segmenters/punkt.rb - About 35 mins 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 ancestor_with_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def ancestor_with_type(type)
                        return unless has_parent?
                        ancestor = @parent
                        type_klass = Treat::Entities.const_get(type.cc)
                        while not ancestor.is_a?(type_klass)
                    Severity: Minor
                    Found in lib/treat/entities/entity/iterable.rb - About 35 mins 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 add_workers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def add_workers(group)
                        self.class_eval do
                          task = group.method
                          add_presets(group)
                          define_method(task) do |worker=nil, options={}|
                    Severity: Minor
                    Found in lib/treat/entities/entity/delegatable.rb - About 35 mins 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

                    Severity
                    Category
                    Status
                    Source
                    Language