theforeman/foreman

View on GitHub
app/models/operatingsystem.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Operatingsystem has 49 methods (exceeds 20 allowed). Consider refactoring.
Open

class Operatingsystem < ApplicationRecord
  audited
  include Authorizable
  include ValidateOsFamily
  include PxeLoaderSupport
Severity: Minor
Found in app/models/operatingsystem.rb - About 6 hrs to fix

    File operatingsystem.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'ostruct'
    require 'uri'
    
    class Operatingsystem < ApplicationRecord
      audited
    Severity: Minor
    Found in app/models/operatingsystem.rb - About 3 hrs to fix

      Method boot_filename has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def boot_filename(host = nil)
          return default_boot_filename if host.nil? || host.pxe_loader.nil?
          return host.foreman_url('iPXE') if host.pxe_loader == 'iPXE Embedded'
          architecture = host.arch.nil? ? '' : host.arch.bootfilename_efi
          if host.subnet&.httpboot? && host.pxe_loader =~ /UEFI HTTP/
      Severity: Minor
      Found in app/models/operatingsystem.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 find_by_to_label has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.find_by_to_label(str)
          os = find_by_description(str.to_s)
          return os if os
          a = str.split(" ")
          b = a[1].split('.') if a[1]
      Severity: Minor
      Found in app/models/operatingsystem.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