benbalter/licensee

View on GitHub

Showing 11 of 13 total issues

Method detect has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def detect(_path = nil)
    Licensee.confidence_threshold = options[:confidence]

    if options[:json]
      say project.to_h.to_json
Severity: Minor
Found in lib/licensee/commands/detect.rb - About 4 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 License has 33 methods (exceeds 20 allowed). Consider refactoring.
Open

  class License
    @all = {}
    @keys_licenses = {}

    class << self
Severity: Minor
Found in lib/licensee/license.rb - About 4 hrs to fix

    File content_helper.rb has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'set'
    require 'digest'
    
    module Licensee
      module ContentHelper
    Severity: Minor
    Found in lib/licensee/content_helper.rb - About 2 hrs to fix

      Method detect has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def detect(_path = nil)
          Licensee.confidence_threshold = options[:confidence]
      
          if options[:json]
            say project.to_h.to_json
      Severity: Minor
      Found in lib/licensee/commands/detect.rb - About 1 hr to fix

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

            def to_h
              hash = {}
              self.class::HASH_METHODS.each do |method|
                key = method.to_s.delete('?').to_sym
                value = public_send(method)
        Severity: Minor
        Found in lib/licensee/hash_helper.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 title_regex has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def title_regex
              return @title_regex if defined? @title_regex
        
              string = name.downcase.sub('*', 'u')
              simple_title_regex = Regexp.new string, 'i'
        Severity: Minor
        Found in lib/licensee/license.rb - About 1 hr to fix

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

              def strip(regex_or_sym)
                return unless _content
          
                if regex_or_sym.is_a?(Symbol)
                  meth = "strip_#{regex_or_sym}"
          Severity: Minor
          Found in lib/licensee/content_helper.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 license_property has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def license_property
                  match = @file.content.match LICENSE_REGEX
                  return match[1].downcase if match && match[1]
          
                  # check for a licenses array property
          Severity: Minor
          Found in lib/licensee/matchers/gemspec.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 title_regex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def title_regex
                return @title_regex if defined? @title_regex
          
                string = name.downcase.sub('*', 'u')
                simple_title_regex = Regexp.new string, 'i'
          Severity: Minor
          Found in lib/licensee/license.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 readme_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def readme_file
                  return unless detect_readme?
                  return @readme if defined? @readme
          
                  @readme = begin
          Severity: Minor
          Found in lib/licensee/projects/project.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 package_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def package_file
                  return unless detect_packages?
                  return @package_file if defined? @package_file
          
                  @package_file = begin
          Severity: Minor
          Found in lib/licensee/projects/project.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