librariesio/libraries.io

View on GitHub
app/models/package_manager/base.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Base has 38 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Base
    COLOR = "#fff"
    BIBLIOTHECARY_SUPPORT = false
    BIBLIOTHECARY_PLANNED = false
    SECURITY_PLANNED = false
Severity: Minor
Found in app/models/package_manager/base.rb - About 5 hrs to fix

    Method save_dependencies has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.save_dependencies(mapped_project)
          name = mapped_project[:name]
          proj = Project.find_by(name: name, platform: self.name.demodulize)
          proj.versions.includes(:dependencies).each do |version|
            next if version.dependencies.any?
    Severity: Minor
    Found in app/models/package_manager/base.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 save has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.save(project)
          return unless project.present?
    
          mapped_project = mapping(project)
          mapped_project = mapped_project.delete_if { |_key, value| value.blank? } if mapped_project.present?
    Severity: Minor
    Found in app/models/package_manager/base.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.update(name)
          proj = project(name)
          save(proj) if proj.present?
        rescue SystemExit, Interrupt
          exit 0
    Severity: Minor
    Found in app/models/package_manager/base.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

    There are no issues that match your filters.

    Category
    Status