jtyost2/CakePHP-Unit-Testing

View on GitHub

Showing 81 of 180 total issues

File firewall.rb has 820 lines of code (exceeds 250 allowed). Consider refactoring.
Open

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..",".."))
require 'puppet/util/firewall'

Puppet::Type.newtype(:firewall) do
  include Puppet::Util::Firewall
Severity: Major
Found in Lib/puphpet/puppet/modules/firewall/lib/puppet/type/firewall.rb - About 1 day to fix

    Function exports has 310 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function(grunt) {
      var merge = require('merge-recursive');
      var env = process.env.APP_ENV || 'dev';
      var fs = require('fs');
    
    
    Severity: Major
    Found in Gruntfile.js - About 1 day to fix

      Method rule_to_hash has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.rule_to_hash(line, table, counter)
          hash = {}
          keys = []
          values = line.dup
      
      

      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 providerBalance has 134 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function providerBalance() {
              return array(
                  'Only a simple base price' => array(
                      100.00,
                      false,
      Severity: Major
      Found in Test/Case/Lib/BalanceCalculationTest.php - About 5 hrs to fix

        File iptables.rb has 349 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'puppet/provider/firewall'
        require 'digest/md5'
        
        Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Firewall do
          include Puppet::Util::Firewall

          Method general_args has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

            def general_args
              debug "Current resource: %s" % resource.class
          
              args = []
              resource_list = self.class.instance_variable_get('@resource_list')

          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

          File Gruntfile.js has 312 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module.exports = function(grunt) {
            var merge = require('merge-recursive');
            var env = process.env.APP_ENV || 'dev';
            var fs = require('fs');
          
          
          Severity: Minor
          Found in Gruntfile.js - About 3 hrs to fix

            Method rule_to_hash has 83 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.rule_to_hash(line, table, counter)
                hash = {}
                keys = []
                values = line.dup
            
            

              Method instances has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.instances
                  debug "[instances]"
                  table = nil
                  chains = []
              
              

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

                def persist_iptables(proto)
                  debug("[persist_iptables]")
              
                  # Basic normalisation for older Facter
                  os_key = Facter.value(:osfamily)
              Severity: Minor
              Found in Lib/puphpet/puppet/modules/firewall/lib/puppet/util/firewall.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 insert_order has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                def insert_order
                  debug("[insert_order]")
                  rules = []
              
                  # Find list of current rules based on chain and table

              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 persist_iptables has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def persist_iptables(proto)
                  debug("[persist_iptables]")
              
                  # Basic normalisation for older Facter
                  os_key = Facter.value(:osfamily)
              Severity: Major
              Found in Lib/puphpet/puppet/modules/firewall/lib/puppet/util/firewall.rb - About 2 hrs to fix

                Method validate_privs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  def validate_privs(set_privs, all_privs)
                    all_privs = all_privs.collect { |p| p.downcase }
                    set_privs = set_privs.collect { |p| p.downcase }
                    invalid_privs = Array.new
                    hints = Array.new

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

                    def retrieve
                      prov = @resource.provider
                      if prov
                        if prov.working_copy_exists?
                          (@should.include?(:latest) && prov.latest?) ? :latest : :present
                Severity: Minor
                Found in Lib/puphpet/puppet/modules/vcsrepo/lib/puppet/type/vcsrepo.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

                File git.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require File.join(File.dirname(__FILE__), '..', 'vcsrepo')
                
                Puppet::Type.type(:vcsrepo).provide(:git, :parent => Puppet::Provider::Vcsrepo) do
                  desc "Supports Git repositories"
                
                
                Severity: Minor
                Found in Lib/puphpet/puppet/modules/vcsrepo/lib/puppet/provider/vcsrepo/git.rb - About 2 hrs to fix

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

                    def self.instances
                      instances = []
                      users.select{ |user| user =~ /.+@/ }.collect do |user|
                        user_string = self.cmd_user(user)
                        query = "SHOW GRANTS FOR #{user_string};"

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

                    def revision
                      update_references
                      current = at_path { git_with_identity('rev-parse', 'HEAD').chomp }
                      return current unless @resource.value(:revision)
                  
                  
                  Severity: Minor
                  Found in Lib/puphpet/puppet/modules/vcsrepo/lib/puppet/provider/vcsrepo/git.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 exists? has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def exists?
                      failcount = 0
                      is_configured = false
                      @resource[:members].each do |host|
                        begin

                  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

                  Function exports has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function(output, files, paths, done) {
                    var fs       = require('fs'),
                        path     = require('path'),
                        exec     = require('child_process').exec,
                        async    = require('async'),
                  Severity: Minor
                  Found in Console/node/asset_builder.js - About 1 hr to fix

                    Method create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def create
                        if !@resource.value(:source)
                          init_repository(@resource.value(:path))
                        else
                          clone_repository(@resource.value(:source), @resource.value(:path))

                    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