dayglojesus/macadmin

View on GitHub
lib/macadmin/dslocal/dslocalnode.rb

Summary

Maintainability
C
1 day
Test Coverage

Class DSLocalNode has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class DSLocalNode
    
    require 'find'
    
    SANDBOX_FILE       = '/System/Library/Sandbox/Profiles/com.apple.opendirectoryd.sb'
Severity: Minor
Found in lib/macadmin/dslocal/dslocalnode.rb - About 3 hrs to fix

    Method active? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def active?
          if needs_sandbox?
            return false unless sandbox_active?
          end
          load_configuration_file
    Severity: Minor
    Found in lib/macadmin/dslocal/dslocalnode.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_directory_structure has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_directory_structure
          return false unless File.exists? @root
          Find.find(@root) do |path|
            stat = File::Stat.new path
            return false unless stat.uid == OWNER and stat.gid == GROUP
    Severity: Minor
    Found in lib/macadmin/dslocal/dslocalnode.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 load_configuration_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_configuration_file
          3.times do
            @file = get_configuration_file
            if File.exists? @file
              break
    Severity: Minor
    Found in lib/macadmin/dslocal/dslocalnode.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

    Avoid too many return statements within this method.
    Open

          return false unless searchpolicy_is_custom?
    Severity: Major
    Found in lib/macadmin/dslocal/dslocalnode.rb - About 30 mins to fix

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

          def create_directories
            begin
              FileUtils.mkdir_p @root unless File.exist? @root
              FileUtils.chmod(0700, @root)
              CHILD_DIRS.each do |child|
      Severity: Minor
      Found in lib/macadmin/dslocal/dslocalnode.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