versioneye/naturalsorter

View on GitHub

Showing 83 of 87 total issues

Method compare_special_cases has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def self.compare_special_cases part1, part2
    result = Versioncmp.check_jquery_versioning(part1, part2)
    return result if !result.to_s.strip.empty?

    digit = part1 if part1.to_s.match(/\d/)
Severity: Minor
Found in lib/versioncmp.rb - About 5 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 compare has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def self.compare(a_val, b_val)

    a_empty = a_val.to_s.empty?
    b_empty = b_val.to_s.empty?

Severity: Minor
Found in lib/versioncmp.rb - About 3 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 does_it_fit_stability? has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def self.does_it_fit_stability?( version_number, stability )
    patch = self.patch?( version_number )
    return true if (stability.casecmp( A_STABILITY_PATCH ) == 0) && patch

    stable = self.stable?( version_number )
Severity: Minor
Found in lib/version_tag_recognizer.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

Class Versioncmp has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

class Versioncmp

  # 'Natural version order' comparison of two version strings
  #
  def self.compare(a_val, b_val)
Severity: Minor
Found in lib/versioncmp.rb - About 2 hrs to fix

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

      def self.stability_tag_for( version )
        if version.to_s.match(/@.*$/)
          spliti = version.split("@")
          return spliti[1]
        else
    Severity: Minor
    Found in lib/version_tag_recognizer.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 natcmp has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def self.natcmp(str1, str2, caseInsensitive=false)
      str1, str2 = str1.dup, str2.dup
      compareExpression = /^(\D*)(\d*)(.*)$/
    
      if caseInsensitive
    Severity: Minor
    Found in lib/natcmp.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 compare has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.compare(a_val, b_val)
    
        a_empty = a_val.to_s.empty?
        b_empty = b_val.to_s.empty?
    
    
    Severity: Minor
    Found in lib/versioncmp.rb - About 1 hr to fix

      Method compare_special_cases has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.compare_special_cases part1, part2
          result = Versioncmp.check_jquery_versioning(part1, part2)
          return result if !result.to_s.strip.empty?
      
          digit = part1 if part1.to_s.match(/\d/)
      Severity: Minor
      Found in lib/versioncmp.rb - About 1 hr to fix

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

          def self.check_the_slice ab, offsets
            ab[0] += ".0" if offsets[0] >= ab[0].length
            ab[1] += ".0" if offsets[0] >= ab[1].length
        
            part1 = Versioncmp.get_a_piece_of_the_cake offsets[0], ab[0]
        Severity: Minor
        Found in lib/versioncmp.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 stable? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.stable? value
            return true if value.to_s.empty?
            return false if value.to_s.match(/\Adev-/i) || value.to_s.match(/-dev\z/i)
            return false if self.preview?( value )
        
        
        Severity: Minor
        Found in lib/version_tag_recognizer.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 is_version_current? has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.is_version_current?(version, newest_version)
              version = version.gsub("~>", "")
              version = version.gsub(" " , "")
              versions = version.split(".")
              newests = newest_version.split(".")
        Severity: Minor
        Found in lib/naturalsorter.rb - About 1 hr to fix

          Method natcmp has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def self.natcmp(str1, str2, caseInsensitive=false)
            str1, str2 = str1.dup, str2.dup
            compareExpression = /^(\D*)(\d*)(.*)$/
          
            if caseInsensitive
          Severity: Minor
          Found in lib/natcmp.rb - About 1 hr to fix

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

              def self.get_a_piece_of_the_cake(offset, cake)
                for z in 0..100
                  offsetz = offset + z
                  break if offsetz > cake.length()
            
            
            Severity: Minor
            Found in lib/versioncmp.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 value_for_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.value_for_key( value )
                return 0  if A_STABILITY_DEV.eql? value
                return 2  if A_STABILITY_SNAPSHOT.eql? value
                return 3  if A_STABILITY_ALPHA.eql? value
                return 4  if A_STABILITY_BETA.eql? value
            Severity: Minor
            Found in lib/version_tag_recognizer.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 value_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.value_for( value )
                return 0  if self.dev? value
                return 2  if self.snapshot? value
                return 3  if self.alpha? value
                return 4  if self.beta? value
            Severity: Minor
            Found in lib/version_tag_recognizer.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 tagged? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.tagged? value
                return true if self.patch?(value)
                return true if self.alpha?(value)
                return true if self.beta?(value)
                return true if self.dev?(value)
            Severity: Minor
            Found in lib/version_tag_recognizer.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 is_version_current? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.is_version_current?(version, newest_version)
                  version = version.gsub("~>", "")
                  version = version.gsub(" " , "")
                  versions = version.split(".")
                  newests = newest_version.split(".")
            Severity: Minor
            Found in lib/naturalsorter.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 check_jquery_versioning has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.check_jquery_versioning(part1, part2)
                # --- START ---- special case for awesome jquery shitty verison numbers
                if ( part1.to_s.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part2.to_s.match(/^[0-9]+$/) != nil )
                  part1_1 = part1.match(/^[0-9]+/)
                  result = Versioncmp.compare_int(part1_1[0], part2)
            Severity: Minor
            Found in lib/versioncmp.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 remove_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.remove_tag value
                if self.patch? value
                  return value.gsub(/\.patch.*$/i, "")
                elsif self.alpha? value
                  new_value = value.gsub(/\.[\w-]*alpha.*$/i, "")
            Severity: Minor
            Found in lib/version_tag_recognizer.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  1 if b_val.length > a_val.length && b_val.to_s.match(/\A#{a_val}-rc.*/i)
            Severity: Major
            Found in lib/versioncmp.rb - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language