jtyost2/CakePHP-Unit-Testing

View on GitHub

Showing 81 of 180 total issues

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

  def handle_create_with_match()
    regex = resource[:match] ? Regexp.new(resource[:match]) : nil
    match_count = lines.select { |l| regex.match(l) }.size
    if match_count > 1 && resource[:multiple].to_s != 'true'
     raise Puppet::Error, "More than one line in file '#{resource[:path]}' matches pattern '#{resource[:match]}'"

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 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

Method general_args has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def general_args
    debug "Current resource: %s" % resource.class

    args = []
    resource_list = self.class.instance_variable_get('@resource_list')

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

      def command()
        if ((! resource[:unless]) or (resource[:unless].empty?))
          if (resource.refreshonly?)
            # So, if there's no 'unless', and we're in "refreshonly" mode,
            # we need to return the target command here.  If we don't,

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

        protected function constructOrderProperty() {
            // Make default sort order(s) more flexible!
            if (is_array($this->order)) {
                foreach ($this->order as $field => $fieldOrDir) {
                    if (is_numeric($field)) { // Format is: $this->order = array('Model.field ASC', 'Model.second DESC');
    Severity: Minor
    Found in Model/AppModel.php - 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 create has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        allvalidchains do |t, chain, table, protocol|
          if chain =~ InternalChains
            # can't create internal chains
            warning "Attempting to create internal chain #{@resource[:name]}"

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

      def cache_lookup(file)
        cache = load_cache
    
        return nil if cache.empty?
    
    
    Severity: Minor
    Found in Lib/puphpet/puppet/modules/stdlib/lib/facter/facter_dot_d.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 testEditPostRequestInvalidData has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testEditPostRequestInvalidData() {
    
            $blogId = '53c69fd8-5840-45d9-add0-7cb374524da5';
            $blogTitle = 'This is an edited blog record';
    
    
    Severity: Minor
    Found in Test/Case/Controller/BlogsControllerTest.php - About 1 hr to fix

      Method icmp_name_to_number has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def icmp_name_to_number(value_icmp, protocol)
          if value_icmp =~ /\d{1,2}$/
            value_icmp
          elsif protocol == 'inet'
            case value_icmp
      Severity: Minor
      Found in Lib/puphpet/puppet/modules/firewall/lib/puppet/util/firewall.rb - About 1 hr to fix

        Method testEditPostRequestInvalidData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testEditPostRequestInvalidData() {
        
                $tagId = '53bccb61-6244-4799-a9ce-5ef974524da5';
                $tagTitle = 'This is an edited tag record';
        
        
        Severity: Minor
        Found in Test/Case/Controller/TagsControllerTest.php - About 1 hr to fix

          Method get_revision has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_revision(rev)
              if !working_copy_exists?
                create
              end
              at_path do

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

            def init_repository(path)
              check_force
              if @resource.value(:ensure) == :bare && working_copy_exists?
                convert_working_copy_to_bare
              elsif @resource.value(:ensure) == :present && bare_exists?

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

            def privileges=(privs)
              unless row_exists?
                create_row
              end
          
          

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

            def self.users(name, vhost)
              @users = {} unless @users
              unless @users[name]
                @users[name] = {}
                rabbitmqctl('list_user_permissions', name).split(/\n/)[1..-2].each do |line|

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

              public function testSendExample() {
                  $recipients = array();
                  $vars = array();
                  $this->Email->expects($this->once())
                      ->method('send')
          Severity: Minor
          Found in Test/Case/Lib/Network/Email/AppEmailTest.php - About 1 hr to fix

            Method provideEnumListArgs has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function provideEnumListArgs() {
                    $properties = array(
                        'field1' => array(
                            'f1-opt1' => 'Field 1, Option 1',
                            'f1-opt2' => 'Field 1, Option 2',
            Severity: Minor
            Found in Test/Case/Model/AppModelTest.php - About 1 hr to fix

              Method testBalance has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function testBalance($basePrice, $couponBool, $couponValue, $couponType, $cancelationInsuranceBool, $cancelationInsurancePercent, $internationalFeeBool, $internationalFee, $expectedOutput) {
              Severity: Major
              Found in Test/Case/Lib/BalanceCalculationTest.php - About 1 hr to fix

                Method testEditPostRequestValidData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function testEditPostRequestValidData() {
                        $blogId = '53c69fd8-5840-45d9-add0-7cb374524da5';
                        $blogTitle = 'This is an edited blog record';
                
                        $Blogs = $this->generate('Blogs', array(
                Severity: Minor
                Found in Test/Case/Controller/BlogsControllerTest.php - About 1 hr to fix

                  Method insert_order has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

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

                      def script_parser(file)
                        result = cache_lookup(file)
                        ttl = cache_time(file)
                    
                        unless result
                    Severity: Minor
                    Found in Lib/puphpet/puppet/modules/stdlib/lib/facter/facter_dot_d.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

                    Severity
                    Category
                    Status
                    Source
                    Language