saltstack/salt

View on GitHub

Showing 17,495 of 17,590 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

Severity: Major
Found in salt/states/apache_module.py and 1 other location - About 6 days to fix
salt/states/apache_site.py on lines 0..97

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 646.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

Severity: Major
Found in salt/states/apache_site.py and 1 other location - About 6 days to fix
salt/states/apache_module.py on lines 0..103

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 646.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File core.py has 2280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
The static grains, these are the core, or built in grains.

When grains are loaded they are not loaded in the same way that modules are
Severity: Major
Found in salt/grains/core.py - About 6 days to fix

    File aptpkg.py has 2231 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    '''
    Support for APT (Advanced Packaging Tool)
    
    .. important::
    Severity: Major
    Found in salt/modules/aptpkg.py - About 6 days to fix

      File gce.py has 2185 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      '''
      Copyright 2013 Google Inc. All Rights Reserved.
      
      Licensed under the Apache License, Version 2.0 (the "License");
      Severity: Major
      Found in salt/cloud/clouds/gce.py - About 6 days to fix

        File app.py has 2181 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # encoding: utf-8
        '''
        A REST API for Salt
        ===================
        
        
        Severity: Major
        Found in salt/netapi/rest_cherrypy/app.py - About 6 days to fix

          Function _virtual has a Cognitive Complexity of 293 (exceeds 5 allowed). Consider refactoring.
          Open

          def _virtual(osdata):
              '''
              Returns what type of virtual hardware is under the hood, kvm or physical
              '''
              # This is going to be a monster, if you are running a vm you can test this
          Severity: Minor
          Found in salt/grains/core.py - About 6 days 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 zabbix.py has 2118 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          '''
          Support for Zabbix
          
          :optdepends:    - zabbix server
          Severity: Major
          Found in salt/modules/zabbix.py - About 5 days to fix

            File zypperpkg.py has 2069 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- coding: utf-8 -*-
            '''
            Package support for openSUSE via the zypper package manager
            
            :depends: - ``rpm`` Python module.  Install with ``zypper install rpm-python``
            Severity: Major
            Found in salt/modules/zypperpkg.py - About 5 days to fix

              File docker_container.py has 2059 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # -*- coding: utf-8 -*-
              '''
              Management of Docker containers
              
              .. versionadded:: 2017.7.0
              Severity: Major
              Found in salt/states/docker_container.py - About 5 days to fix

                File napalm_network.py has 2052 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # -*- coding: utf-8 -*-
                '''
                NAPALM Network
                ==============
                
                
                Severity: Major
                Found in salt/modules/napalm_network.py - About 5 days to fix

                  Function query has a Cognitive Complexity of 272 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def query(url,
                            method='GET',
                            params=None,
                            data=None,
                            data_file=None,
                  Severity: Minor
                  Found in salt/utils/http.py - About 5 days 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

                  Function deploy_script has a Cognitive Complexity of 269 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def deploy_script(host,
                                    port=22,
                                    timeout=900,
                                    username='root',
                                    password=None,
                  Severity: Minor
                  Found in salt/utils/cloud.py - About 5 days 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  def disassociate_vpc_from_hosted_zone(HostedZoneId=None, Name=None, VPCId=None,
                                                       VPCName=None, VPCRegion=None, Comment=None,
                                                       region=None, key=None, keyid=None, profile=None):
                      '''
                      Disassociates an Amazon VPC from a private hosted zone.
                  Severity: Major
                  Found in salt/modules/boto3_route53.py and 1 other location - About 5 days to fix
                  salt/modules/boto3_route53.py on lines 465..567

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 565.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  def associate_vpc_with_hosted_zone(HostedZoneId=None, Name=None, VPCId=None,
                                                     VPCName=None, VPCRegion=None, Comment=None,
                                                     region=None, key=None, keyid=None, profile=None):
                      '''
                      Associates an Amazon VPC with a private hosted zone.
                  Severity: Major
                  Found in salt/modules/boto3_route53.py and 1 other location - About 5 days to fix
                  salt/modules/boto3_route53.py on lines 570..662

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 565.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  File azurearm_network.py has 1998 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # -*- coding: utf-8 -*-
                  '''
                  Azure (ARM) Network State Module
                  
                  .. versionadded:: 2019.2.0
                  Severity: Major
                  Found in salt/states/azurearm_network.py - About 5 days to fix

                    File azurearm_network.py has 1987 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    # -*- coding: utf-8 -*-
                    '''
                    Azure (ARM) Network Execution Module
                    
                    .. versionadded:: 2019.2.0
                    Severity: Major
                    Found in salt/modules/azurearm_network.py - About 5 days to fix

                      Function _present has a Cognitive Complexity of 264 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _present(name,
                                  block_icmp=None,
                                  prune_block_icmp=False,
                                  default=None,
                                  masquerade=False,
                      Severity: Minor
                      Found in salt/states/firewalld.py - About 5 days 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 __init__.py has 1962 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      # -*- coding: utf-8 -*-
                      '''
                      The top level interface used to translate configuration data back to the
                      correct cloud modules
                      '''
                      Severity: Major
                      Found in salt/cloud/__init__.py - About 5 days to fix

                        Cyclomatic complexity is too high in function latest. (267)
                        Open

                        def latest(name,
                                   rev='HEAD',
                                   target=None,
                                   branch=None,
                                   user=None,
                        Severity: Minor
                        Found in salt/states/git.py by radon

                        Cyclomatic Complexity

                        Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                        Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                        Construct Effect on CC Reasoning
                        if +1 An if statement is a single decision.
                        elif +1 The elif statement adds another decision.
                        else +0 The else statement does not cause a new decision. The decision is at the if.
                        for +1 There is a decision at the start of the loop.
                        while +1 There is a decision at the while statement.
                        except +1 Each except branch adds a new conditional path of execution.
                        finally +0 The finally block is unconditionally executed.
                        with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                        assert +1 The assert statement internally roughly equals a conditional statement.
                        Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                        Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                        Source: http://radon.readthedocs.org/en/latest/intro.html

                        Severity
                        Category
                        Status
                        Source
                        Language