saltstack/salt

View on GitHub
salt/modules/nftables.py

Summary

Maintainability
F
1 wk
Test Coverage

File nftables.py has 738 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Support for nftables
'''
from __future__ import absolute_import, print_function, unicode_literals
Severity: Major
Found in salt/modules/nftables.py - About 1 day to fix

    Function build_rule has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    def build_rule(table=None, chain=None, command=None, position='', full=None, family='ipv4',
                   **kwargs):
        '''
        Build a well-formatted nftables rule based on kwargs.
        A `table` and `chain` are not required, unless `full` is True.
    Severity: Minor
    Found in salt/modules/nftables.py - About 5 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

    Cyclomatic complexity is too high in function build_rule. (33)
    Open

    def build_rule(table=None, chain=None, command=None, position='', full=None, family='ipv4',
                   **kwargs):
        '''
        Build a well-formatted nftables rule based on kwargs.
        A `table` and `chain` are not required, unless `full` is True.
    Severity: Minor
    Found in salt/modules/nftables.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

    Function new_chain has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def new_chain(table='filter', chain=None, table_type=None, hook=None, priority=None, family='ipv4'):
        '''
        .. versionadded:: 2014.7.0
    
        Create new chain to the specified table.
    Severity: Minor
    Found in salt/modules/nftables.py - 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

    Function build_rule has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def build_rule(table=None, chain=None, command=None, position='', full=None, family='ipv4',
                   **kwargs):
        '''
        Build a well-formatted nftables rule based on kwargs.
        A `table` and `chain` are not required, unless `full` is True.
    Severity: Minor
    Found in salt/modules/nftables.py - About 1 hr to fix

      Function insert has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def insert(table='filter', chain=None, position=None, rule=None, family='ipv4'):
          '''
          Insert a rule into the specified table & chain, at the specified position.
      
          If position is not specified, rule will be inserted in first position.
      Severity: Minor
      Found in salt/modules/nftables.py - About 55 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

      Function get_rule_handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_rule_handle(table='filter', chain=None, rule=None, family='ipv4'):
          '''
          Get the handle for a particular rule
      
          This function accepts a rule in a standard nftables command format,
      Severity: Minor
      Found in salt/modules/nftables.py - 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

      Function append has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def append(table='filter', chain=None, rule=None, family='ipv4'):
          '''
          Append a rule to the specified table & chain.
      
          This function accepts a rule in a standard nftables command format,
      Severity: Minor
      Found in salt/modules/nftables.py - 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

      Function delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def delete(table, chain=None, position=None, rule=None, family='ipv4'):
          '''
          Delete a rule from the specified table & chain, specifying either the rule
              in its entirety, or the rule's position in the chain.
      
      
      Severity: Minor
      Found in salt/modules/nftables.py - 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

      Function flush has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def flush(table='filter', chain='', family='ipv4'):
          '''
          Flush the chain in the specified table, flush all chains in the specified
          table if chain is not specified.
      
      
      Severity: Minor
      Found in salt/modules/nftables.py - 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

      Function get_saved_rules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_saved_rules(conf_file=None):
          '''
          Return a data structure of the rules in the conf file
      
          CLI Example:
      Severity: Minor
      Found in salt/modules/nftables.py - 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 function.
      Open

              return ret
      Severity: Major
      Found in salt/modules/nftables.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return res
        Severity: Major
        Found in salt/modules/nftables.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return ret
          Severity: Major
          Found in salt/modules/nftables.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return ret
            Severity: Major
            Found in salt/modules/nftables.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return {'result': False,
              Severity: Major
              Found in salt/modules/nftables.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return ret
                Severity: Major
                Found in salt/modules/nftables.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return ret
                  Severity: Major
                  Found in salt/modules/nftables.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return {'result': True, 'handle': match.group('handle')}
                    Severity: Major
                    Found in salt/modules/nftables.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return ret
                      Severity: Major
                      Found in salt/modules/nftables.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return False
                        Severity: Major
                        Found in salt/modules/nftables.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return ret
                          Severity: Major
                          Found in salt/modules/nftables.py - About 30 mins to fix

                            Function check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def check(table='filter', chain=None, rule=None, family='ipv4'):
                                '''
                                Check for the existence of a rule in the table and chain
                            
                                This function accepts a rule in a standard nftables command format,
                            Severity: Minor
                            Found in salt/modules/nftables.py - 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

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

                                if 'sports' in kwargs:
                                    # nftables reverse sorts the ports from
                                    # high to low, create rule like this
                                    # so that the check will work
                                    _sports = kwargs['sports'].split(',')
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 6 hrs to fix
                            salt/modules/nftables.py on lines 169..179

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

                            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

                                if 'dports' in kwargs:
                                    # nftables reverse sorts the ports from
                                    # high to low, create rule like this
                                    # so that the check will work
                                    _dports = kwargs['dports'].split(',')
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 6 hrs to fix
                            salt/modules/nftables.py on lines 181..191

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

                            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

                                if 'dport' in kwargs:
                                    kwargs['dport'] = six.text_type(kwargs['dport'])
                                    if ':' in kwargs['dport']:
                                        kwargs['dport'] = kwargs['dport'].replace(':', '-')
                                    rule += 'dport {{ {0} }} '.format(kwargs['dport'])
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 5 hrs to fix
                            salt/modules/nftables.py on lines 162..167

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

                            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

                                if 'sport' in kwargs:
                                    kwargs['sport'] = six.text_type(kwargs['sport'])
                                    if ':' in kwargs['sport']:
                                        kwargs['sport'] = kwargs['sport'].replace(':', '-')
                                    rule += 'sport {{ {0} }} '.format(kwargs['sport'])
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 5 hrs to fix
                            salt/modules/nftables.py on lines 155..160

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

                            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 3 locations. Consider refactoring.
                            Open

                                if len(out) == 0:
                                    ret['result'] = True
                                    ret['comment'] = 'Deleted rule "{0}" in chain {1} in table {2} in family {3}.'.\
                                                     format(rule, chain, table, family)
                                else:
                            Severity: Major
                            Found in salt/modules/nftables.py and 2 other locations - About 2 hrs to fix
                            salt/modules/nftables.py on lines 797..803
                            salt/modules/nftables.py on lines 871..877

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

                            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 3 locations. Consider refactoring.
                            Open

                                if len(out) == 0:
                                    ret['result'] = True
                                    ret['comment'] = 'Added rule "{0}" chain {1} in table {2} in family {3}.'.\
                                                     format(rule, chain, table, family)
                                else:
                            Severity: Major
                            Found in salt/modules/nftables.py and 2 other locations - About 2 hrs to fix
                            salt/modules/nftables.py on lines 871..877
                            salt/modules/nftables.py on lines 938..944

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

                            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 3 locations. Consider refactoring.
                            Open

                                if len(out) == 0:
                                    ret['result'] = True
                                    ret['comment'] = 'Added rule "{0}" chain {1} in table {2} in family {3}.'.\
                                                     format(rule, chain, table, family)
                                else:
                            Severity: Major
                            Found in salt/modules/nftables.py and 2 other locations - About 2 hrs to fix
                            salt/modules/nftables.py on lines 797..803
                            salt/modules/nftables.py on lines 938..944

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

                            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

                                try:
                                    with salt.utils.files.fopen(filename, 'wb') as _fh:
                                        # Write out any changes
                                        _fh.writelines(salt.utils.data.encode(rules))
                                except (IOError, OSError) as exc:
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 2 hrs to fix
                            salt/modules/ssh.py on lines 1240..1245

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

                            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

                                if not out:
                                    ret['comment'] = 'Chain {0} in table {1} in family {2} deleted'.\
                                                     format(chain, table, family)
                                    ret['result'] = True
                                else:
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 2 hrs to fix
                            salt/modules/nftables.py on lines 687..693

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

                            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

                                if not out:
                                    ret['comment'] = 'Chain {0} in table {1} in family {2} created'.\
                                                     format(chain, table, family)
                                    ret['result'] = True
                                else:
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 2 hrs to fix
                            salt/modules/nftables.py on lines 736..742

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

                            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

                                if not out:
                                    ret['comment'] = 'Table {0} in family {1} created'.\
                                                     format(table, family)
                                    ret['result'] = True
                                else:
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 1 hr to fix
                            salt/modules/nftables.py on lines 621..627

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

                            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

                                if not out:
                                    ret['comment'] = 'Table {0} in family {1} deleted'.\
                                                     format(table, family)
                                    ret['result'] = True
                                else:
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 1 hr to fix
                            salt/modules/nftables.py on lines 581..587

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

                            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 version():
                                '''
                                Return version from nftables --version
                            
                                CLI Example:
                            Severity: Major
                            Found in salt/modules/nftables.py and 1 other location - About 1 hr to fix
                            salt/modules/ipset.py on lines 130..143

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

                            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 6 locations. Consider refactoring.
                            Open

                                if 'jump' in kwargs:
                                    after_jump.append('{0} '.format(kwargs['jump']))
                                    del kwargs['jump']
                            Severity: Major
                            Found in salt/modules/nftables.py and 5 other locations - About 30 mins to fix
                            salt/modules/nftables.py on lines 201..203
                            salt/modules/nftables.py on lines 205..207
                            salt/modules/nftables.py on lines 209..211
                            salt/modules/nftables.py on lines 213..215
                            salt/modules/nftables.py on lines 217..219

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

                            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 6 locations. Consider refactoring.
                            Open

                                if 'j' in kwargs:
                                    after_jump.append('{0} '.format(kwargs['j']))
                                    del kwargs['j']
                            Severity: Major
                            Found in salt/modules/nftables.py and 5 other locations - About 30 mins to fix
                            salt/modules/nftables.py on lines 197..199
                            salt/modules/nftables.py on lines 205..207
                            salt/modules/nftables.py on lines 209..211
                            salt/modules/nftables.py on lines 213..215
                            salt/modules/nftables.py on lines 217..219

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

                            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 6 locations. Consider refactoring.
                            Open

                                if 'to-ports' in kwargs:
                                    after_jump.append('--to-ports {0} '.format(kwargs['to-ports']))
                                    del kwargs['to-ports']
                            Severity: Major
                            Found in salt/modules/nftables.py and 5 other locations - About 30 mins to fix
                            salt/modules/nftables.py on lines 197..199
                            salt/modules/nftables.py on lines 201..203
                            salt/modules/nftables.py on lines 205..207
                            salt/modules/nftables.py on lines 213..215
                            salt/modules/nftables.py on lines 217..219

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

                            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 6 locations. Consider refactoring.
                            Open

                                if 'reject-with' in kwargs:
                                    after_jump.append('--reject-with {0} '.format(kwargs['reject-with']))
                                    del kwargs['reject-with']
                            Severity: Major
                            Found in salt/modules/nftables.py and 5 other locations - About 30 mins to fix
                            salt/modules/nftables.py on lines 197..199
                            salt/modules/nftables.py on lines 201..203
                            salt/modules/nftables.py on lines 205..207
                            salt/modules/nftables.py on lines 209..211
                            salt/modules/nftables.py on lines 213..215

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

                            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 6 locations. Consider refactoring.
                            Open

                                if 'to-port' in kwargs:
                                    after_jump.append('--to-port {0} '.format(kwargs['to-port']))
                                    del kwargs['to-port']
                            Severity: Major
                            Found in salt/modules/nftables.py and 5 other locations - About 30 mins to fix
                            salt/modules/nftables.py on lines 197..199
                            salt/modules/nftables.py on lines 201..203
                            salt/modules/nftables.py on lines 209..211
                            salt/modules/nftables.py on lines 213..215
                            salt/modules/nftables.py on lines 217..219

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

                            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 6 locations. Consider refactoring.
                            Open

                                if 'to-destination' in kwargs:
                                    after_jump.append('--to-destination {0} '.format(kwargs['to-destination']))
                                    del kwargs['to-destination']
                            Severity: Major
                            Found in salt/modules/nftables.py and 5 other locations - About 30 mins to fix
                            salt/modules/nftables.py on lines 197..199
                            salt/modules/nftables.py on lines 201..203
                            salt/modules/nftables.py on lines 205..207
                            salt/modules/nftables.py on lines 209..211
                            salt/modules/nftables.py on lines 217..219

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

                            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

                            There are no issues that match your filters.

                            Category
                            Status