dayglojesus/macadmin

View on GitHub

Showing 17 of 17 total issues

Method get_upk_info has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

      def get_upk_info(name, state, upk_subkeys)
        info = nil
        if upk_subkeys
          results = upk_subkeys.inject({}) do |results, dict|
            if dict['pfm_upk_input_keys'].include? name
Severity: Minor
Found in lib/macadmin/mcx.rb - About 4 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

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 process_domain has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

          def process_domain(domain, domain_dict)
            manifest = "#{MANIFESTS}/#{domain}.manifest/Contents/Resources/#{domain}.manifest"
            upk_subkeys = load_upk_subkeys(manifest)
            domain_dict.inject({}) do |result, (enforcement, enforcement_array)|
              enforcement_array.inject({}) do |hash, dict|
    Severity: Minor
    Found in lib/macadmin/mcx.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 method_missing has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def method_missing(meth, *args, &block)
          if args.empty?
            return self[meth.to_s] if self[meth.to_s]
            return nil if defaults(@data)[meth.to_s]
          else
    Severity: Minor
    Found in lib/macadmin/dslocal.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 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(args)
          error = nil
          hash = nil
          required_keys = [:entropy, :salt, :iterations]
          if args.is_a? Array
    Severity: Minor
    Found in lib/macadmin/shadowhash.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 get_upk_info has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def get_upk_info(name, state, upk_subkeys)
            info = nil
            if upk_subkeys
              results = upk_subkeys.inject({}) do |results, dict|
                if dict['pfm_upk_input_keys'].include? name
    Severity: Minor
    Found in lib/macadmin/mcx.rb - About 1 hr to fix

      Method process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def process(content)
              @document['mcx_application_data'][@domain] = {}
              content.each do |pref_name, pref_dict|
                state = pref_dict['state']
                enforcement = (state.eql?('always') ? 'Forced' : 'Set-Once')
      Severity: Minor
      Found in lib/macadmin/mcx.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

      Avoid deeply nested control flow statements.
      Open

                      results = results.select { |k,v| v if k =~ /-managed\z/ }
      Severity: Major
      Found in lib/macadmin/mcx.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        results = results.select { |k,v| v if k =~ /\Auser\z/ }
        Severity: Major
        Found in lib/macadmin/mcx.rb - About 45 mins to fix

          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

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

              def exists?
                if self.legacy?
                  password_on_disk = SaltedSHA1.create_from_shadowhash_file self.generateduid[0]
                  return false unless password_on_disk
                  return false unless password_on_disk.password.eql? @password.password
          Severity: Minor
          Found in lib/macadmin/dslocal/user.rb - About 35 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

          Method get_all_attribs_of_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_all_attribs_of_type(type, records)
                type = type.to_s
                begin
                  attribs = []
                  unless records.empty?
          Severity: Minor
          Found in lib/macadmin/dslocal.rb - About 35 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

          Method next_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def next_id(min, ids)
                ids.flatten!
                ids.collect! { |id| id.to_i }
                begin
                  ids.sort!.uniq!
          Severity: Minor
          Found in lib/macadmin/dslocal.rb - About 35 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

            Severity
            Category
            Status
            Source
            Language