louismullie/treat

View on GitHub

Showing 122 of 128 total issues

Method category has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def self.category(entity, options = {})

    tag = entity.check_has(:tag)
    
    return 'unknown' if tag.nil? || tag == ''
Severity: Minor
Found in lib/treat/workers/lexicalizers/categorizers/from_tag.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

Method recurse has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def self.recurse(entity, options)
    spaces, string = '', ''
    options[:indent].times { spaces << ' ' }
    attributes = " id='#{entity.id}'"
    if !entity.features.nil? && entity.features.size != 0
Severity: Minor
Found in lib/treat/workers/formatters/serializers/xml.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

Method stem has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.stem(word, options = {})
    # Copy the word and convert it to a string.
    w = word.to_s
    return w if w.length < 3
    # Map initial y to Y so that the patterns
Severity: Major
Found in lib/treat/workers/inflectors/stemmers/porter.rb - About 2 hrs to fix

    Method tf_idf has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.tf_idf(entity, options={})
        l = Treat.languages[entity.language]
        if l.respond_to?(:stop_words)
          @@cw[entity.language] = l.stop_words
          return 0 if @@cw[entity.language].include?(entity.value)
    Severity: Major
    Found in lib/treat/workers/extractors/tf_idf/native.rb - About 2 hrs to fix

      Method from_folder has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def from_folder(folder)
      
          return if Reserved.include?(folder)
      
          unless FileTest.directory?(folder)
      Severity: Minor
      Found in lib/treat/entities/entity/buildable.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

      Method magic has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def magic(sym, *args)
      
          # Cache this for performance.
          @@entities_regexp ||= "(#{Treat.core.entities.list.join('|')})"
          @@cats_regexp ||= "(#{Treat.linguistics.categories.join('|')})"
      Severity: Major
      Found in lib/treat/entities/entity/magical.rb - About 2 hrs to fix

        Method build has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.build(xml, remove_last = false)
            # Read in the XML file.
            reader = Nokogiri::XML::Reader.from_memory(xml)
            entity = nil
            pd = 0
        Severity: Major
        Found in lib/treat/workers/processors/parsers/enju.rb - About 2 hrs to fix

          Method split has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.split(string, options)
          
              s = " " + string + " "
          
              s.gsub!(/‘/,"'")
          Severity: Minor
          Found in lib/treat/workers/processors/tokenizers/ptb.rb - About 2 hrs to fix

            Method extended has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.extended(group)
            
                group.module_eval do
                  
                  class << self
            Severity: Minor
            Found in lib/treat/workers/groupable.rb - About 1 hr to fix

              Method cleanup_attributes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.cleanup_attributes(name, attributes)
                  
                  new_attr = {}
                  edges = {}
                  pred = attributes.delete('pred')
              Severity: Minor
              Found in lib/treat/workers/processors/parsers/enju.rb - About 1 hr to fix

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

                    def language(extractor = nil, options = {})
                  
                      return Treat.core.language.default if
                      !Treat.core.language.detect
                
                
                Severity: Minor
                Found in lib/treat/proxies/language.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 keywords has a Cognitive Complexity of 14 (exceeds 5 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

                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 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.recurse(entity, options)
                    spaces, string = '', ''
                    options[:indent].times { spaces << ' ' }
                    attributes = " id='#{entity.id}'"
                    if !entity.features.nil? && entity.features.size != 0
                Severity: Minor
                Found in lib/treat/workers/formatters/serializers/xml.rb - About 1 hr to fix

                  Method print_debug has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def print_debug(entity, task, worker, group, options)
                      # Get a list of the worker's targets.
                      targets = group.targets.map(&:to_s)
                      
                      # List the worker's targets as either
                  Severity: Minor
                  Found in lib/treat/entities/entity/debuggable.rb - About 1 hr to fix

                    Method build has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def build(*args)
                    
                        # This probably needs some doc.
                        if args.size == 0
                          file_or_value = ''
                    Severity: Minor
                    Found in lib/treat/entities/entity/buildable.rb - About 1 hr to fix

                      Method recurse has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.recurse(node, html_node, level = 1)
                      
                          html_node.children.each do |child|
                            
                            next if child.name == 'text'
                      Severity: Minor
                      Found in lib/treat/workers/processors/chunkers/html.rb - About 1 hr to fix

                        Method unserialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def self.unserialize(entity, options={})
                            
                            db = options.delete(:db)
                            selector = options
                            
                        Severity: Minor
                        Found in lib/treat/workers/formatters/unserializers/mongo.rb - About 1 hr to fix

                          Method tag has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def self.tag(entity, options = {})
                          
                              # Create the tagger if necessary
                              @@tagger ||= ::Brill::Tagger.new(options[:lexicon],
                              options[:lexical_rules], options[:contextual_rules])
                          Severity: Minor
                          Found in lib/treat/workers/lexicalizers/taggers/brill.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 num_children_with_feature has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def num_children_with_feature(feature, value = nil, recursive = true)
                              i = 0
                              m = method(recursive ? :each_entity : :each)
                              m.call do |c|
                                next unless c.has?(feature)
                          Severity: Minor
                          Found in lib/treat/entities/entity/iterable.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 name_tag has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def self.name_tag(entity, options = {})
                          
                              language = entity.language
                              Treat::Loaders::Stanford.load(language)
                              
                          Severity: Minor
                          Found in lib/treat/workers/extractors/name_tag/stanford.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

                          Severity
                          Category
                          Status
                          Source
                          Language