librariesio/libraries.io

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

Summary

Maintainability
C
1 day
Test Coverage

Class Base has 37 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 4 hrs to fix

    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?
          return false unless 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 save_dependencies has a Cognitive Complexity of 12 (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|
            deps = dependencies(name, version.number, mapped_project) rescue []
    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 27 lines of code (exceeds 25 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?
          return false unless mapped_project.present?
    Severity: Minor
    Found in app/models/package_manager/base.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status