louismullie/treat

View on GitHub

Showing 122 of 128 total issues

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

Avoid too many return statements within this method.
Open

    return Ptc[entity.to_s] if entity.type == :punctuation
Severity: Major
Found in lib/treat/workers/lexicalizers/categorizers/from_tag.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return cat[ts]
    Severity: Major
    Found in lib/treat/workers/lexicalizers/categorizers/from_tag.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return tok.tag if isolated_token
      Severity: Major
      Found in lib/treat/workers/lexicalizers/taggers/stanford.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return 'G' if entity.is_a?(Treat::Entities::Group)
        Severity: Major
        Found in lib/treat/workers/lexicalizers/taggers/lingua.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return :unknown if cat == nil
          Severity: Major
          Found in lib/treat/workers/lexicalizers/categorizers/from_tag.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return 'G' if entity.is_a?(Treat::Entities::Group)
            Severity: Major
            Found in lib/treat/workers/lexicalizers/taggers/brill.rb - About 30 mins to fix

              Method parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.parse(entity, options = {})
              
                  val, lang = entity.to_s, entity.language.intern
              
                  Treat::Loaders::Stanford.load(lang)
              Severity: Minor
              Found in lib/treat/workers/processors/parsers/stanford.rb - About 25 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_serialized_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def from_serialized_file(file)
              
                  unless File.readable?(file)
                    raise Treat::Exception,
                    "Path '#{file}' does not "+
              Severity: Minor
              Found in lib/treat/entities/entity/buildable.rb - About 25 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 export has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def export(entity, exports)
                  unless @question.target == entity.type
                    targ, type = @question.target, entity.type
                    raise Treat::Exception, 
                    "This classification problem targets " +
              Severity: Minor
              Found in lib/treat/learning/problem.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def initialize(name, target, default = nil, type = :continuous)
                  unless name.is_a?(Symbol)
                    raise Treat::Exception, 
                    "Question name should be a symbol."
                  end
              Severity: Minor
              Found in lib/treat/learning/question.rb - About 25 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 remove_time_from_ancestors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.remove_time_from_ancestors(entity, time)
                  entity.ancestors_with_type(:phrase).each do |a|
                    next if !a.has?(:time)
                    return false unless a.get(:time).to_s == time.to_s
                    a.unset(:time, :time_recurrence, 
              Severity: Minor
              Found in lib/treat/workers/extractors/time/nickel.rb - About 25 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 << has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def <<(entities, clear_parent = true)
                    entities = (entities.is_a?(::String) ||
                    entities.is_a?(::Numeric)) ? 
                    entities.to_entity : entities
                    entities = entities.is_a?(::Array) ?
              Severity: Minor
              Found in lib/treat/entities/entity.rb - About 25 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 install has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.install(language = 'english')
              
                  # Require the Rubygem dependency installer.
                  silence_warnings do
                    require 'rubygems/dependency_installer'
              Severity: Minor
              Found in lib/treat/core/installer.rb - About 25 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 serialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.serialize(entity, options = {})
              
                  options = DefaultOptions.merge(options)
                  options[:stop_at] = options[:stop_at] ?
                  Treat::Entities.const_get(
              Severity: Minor
              Found in lib/treat/workers/formatters/serializers/mongo.rb - About 25 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 sense has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.sense(word, options = nil)
              
                  category = word.check_has(:category)
              
                  if !options[:nym]
              Severity: Minor
              Found in lib/treat/workers/lexicalizers/sensers/wordnet.rb - About 25 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 remove_time_from_ancestors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.remove_time_from_ancestors(entity, time)
                  
                  entity.ancestors_with_type(:phrase).each do |a|
                    
                    next if !a.has?(:time)
              Severity: Minor
              Found in lib/treat/workers/extractors/time/chronic.rb - About 25 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 align_tags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

               def self.align_tags(tags, tag_sets)
                 wttc = {}
                 tags.each_slice(2) do |desc, tags|
                   category = desc.gsub(',', ' ,').
                   split(' ')[0].downcase
              Severity: Minor
              Found in lib/treat/config/tags.rb - About 25 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 remove_time_from_ancestors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.remove_time_from_ancestors(entity, time)
                  
                  entity.ancestors_with_type(:phrase).each do |a|
                    
                    next if !a.has?(:time)
              Severity: Minor
              Found in lib/treat/workers/extractors/time/ruby.rb - About 25 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 did_you_mean? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.did_you_mean?(list, name)
                  return '' # Fix
                  list = list.map { |e| e.to_s }
                  name = name.to_s
                  sugg = []
              Severity: Minor
              Found in lib/treat/helpers/help.rb - About 25 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