louismullie/treat

View on GitHub

Showing 122 of 128 total issues

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

  def self.keywords(entity, options = {})
    
    options = DefaultOptions.merge(options)
    tf_idfs = {}
    
Severity: Minor
Found in lib/treat/workers/extractors/keywords/tf_idf.rb - About 1 hr to fix

    Method add_presets has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_presets(group)
    
        opt = group.preset_option
        return unless opt
    
    
    Severity: Minor
    Found in lib/treat/entities/entity/delegatable.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 load has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.load(klass, name, language = nil)
        
        return if @@loaded[klass]
        
        language ||= Treat.core.language.default
    Severity: Minor
    Found in lib/treat/loaders/bind_it.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 detect_format has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.detect_format(filename, default_to = nil)
        
        default_to ||= DefaultOptions[:default_to]
        ext = filename.scan(ExtensionRegexp)
        ext = (ext.is_a?(Array) && ext[0] && ext[0][0]) ? ext[0][0] : ''
    Severity: Minor
    Found in lib/treat/workers/formatters/readers/autoselect.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 tag has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.tag(entity, options = {})
        
        options = DefaultOptions.merge(options)
        
        @@tagger ||= ::EngTagger.new(options)
    Severity: Minor
    Found in lib/treat/workers/lexicalizers/taggers/lingua.rb - About 1 hr to fix

      Method initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(question, *exports)
          unless question.is_a?(Treat::Learning::Question)
            raise Treat::Exception,
            "The first argument to initialize " +
            "should be an instance of " +
      Severity: Minor
      Found in lib/treat/learning/problem.rb - About 1 hr to fix

        Method initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(name, default = nil, proc_string = nil)
            unless name.is_a?(Symbol)
              raise Treat::Exception,
              "The first argument to initialize should "+
              "be a symbol representing the name of the export."
        Severity: Minor
        Found in lib/treat/learning/export.rb - About 1 hr to fix

          Method index has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.index(collection, options = {})
          
              unless collection.get(:folder)
                raise Treat::Exception,
                "Only collections stored on disk " +
          Severity: Minor
          Found in lib/treat/workers/retrievers/indexers/ferret.rb - About 1 hr to fix

            Method do_serialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.do_serialize(entity, options)
            
                children = []
            
                if options[:recursive] && entity.has_children?
            Severity: Minor
            Found in lib/treat/workers/formatters/serializers/mongo.rb - About 55 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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def initialize(name, default = nil, proc_string = nil)
                unless name.is_a?(Symbol)
                  raise Treat::Exception,
                  "The first argument to initialize should "+
                  "be a symbol representing the name of the export."
            Severity: Minor
            Found in lib/treat/learning/export.rb - About 55 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 recurse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.recurse(java_node, ruby_node, tag_set)
                
                java_node.children.each do |java_child|
            
                  label = java_child.label
            Severity: Minor
            Found in lib/treat/workers/processors/parsers/stanford.rb - About 55 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 chunk has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.chunk(entity, options = {})
                
                entity.check_hasnt_children
                zones = entity.to_s.split("\n")
                current = entity
            Severity: Minor
            Found in lib/treat/workers/processors/chunkers/txt.rb - About 55 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 declense has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.declense(entity, options = {})
            
                cat = entity.get(:category)
                return if cat && !POS.include?(cat)
                
            Severity: Minor
            Found in lib/treat/workers/inflectors/declensors/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

            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 ? v.inspect : ' -- '
            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[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_i 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 from_marshal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.from_marshal(options)
                      file = options[:file]
                      data = Marshal.load(File.binread(file))
                      problem, items = *data
                      problem.features.each do |feature|
                  Severity: Minor
                  Found in lib/treat/learning/data_set.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 anything_from_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def anything_from_string(string)
                      case self.mn.downcase.intern
                      when :document
                        folder = Treat.paths.files
                        if folder[-1] == '/'
                  Severity: Minor
                  Found in lib/treat/entities/entity/buildable.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

                  Severity
                  Category
                  Status
                  Source
                  Language