rubygems/rubygems

View on GitHub
lib/rubygems/specification_policy.rb

Summary

Maintainability
D
2 days
Test Coverage

File specification_policy.rb has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "user_interaction"

class Gem::SpecificationPolicy
  include Gem::UserInteraction

Severity: Minor
Found in lib/rubygems/specification_policy.rb - About 5 hrs to fix

    Class SpecificationPolicy has 35 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Gem::SpecificationPolicy
      include Gem::UserInteraction
    
      VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:
    
    
    Severity: Minor
    Found in lib/rubygems/specification_policy.rb - About 4 hrs to fix

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

        def validate_metadata
          metadata = @specification.metadata
      
          unless Hash === metadata
            error "metadata must be a hash"
      Severity: Minor
      Found in lib/rubygems/specification_policy.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 validate_dependencies has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_dependencies # :nodoc:
          warning_messages = []
          @specification.dependencies.each do |dep|
            if dep.name == @specification.name # warn on self reference
              warning_messages << "Self referencing dependency is unnecessary and strongly discouraged."
      Severity: Minor
      Found in lib/rubygems/specification_policy.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 validate_permissions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_permissions
          return if Gem.win_platform?
      
          @specification.files.each do |file|
            next unless File.file?(file)
      Severity: Minor
      Found in lib/rubygems/specification_policy.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 validate_lazy_metadata has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_lazy_metadata
          unless @specification.authors.grep(LAZY_PATTERN).empty?
            error "#{LAZY} is not an author"
          end
      
      
      Severity: Minor
      Found in lib/rubygems/specification_policy.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 validate_licenses has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_licenses
          licenses = @specification.licenses
      
          licenses.each do |license|
            next if Gem::Licenses.match?(license) || license.nil?
      Severity: Minor
      Found in lib/rubygems/specification_policy.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 validate_dependencies has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def validate_dependencies # :nodoc:
          warning_messages = []
          @specification.dependencies.each do |dep|
            if dep.name == @specification.name # warn on self reference
              warning_messages << "Self referencing dependency is unnecessary and strongly discouraged."
      Severity: Minor
      Found in lib/rubygems/specification_policy.rb - About 1 hr to fix

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

          def validate_array_attribute(field)
            val = @specification.send(field)
            klass = case field
                    when :dependencies then
                      Gem::Dependency
        Severity: Minor
        Found in lib/rubygems/specification_policy.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

        TODO found
        Open

            # TODO: raise at some given date
        Severity: Minor
        Found in lib/rubygems/specification_policy.rb by fixme

        There are no issues that match your filters.

        Category
        Status