BenIlies/NoPASARAN

View on GitHub

Showing 89 of 89 total issues

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

    def stop_sniffer(self):
        """
        Stop the sniffer for the state machine.
        """
        logging.debug('Stopping sniffer for machine with ID: {}'.format(self.machine_id))
Severity: Minor
Found in nopasaran/machines/state_machine.py and 1 other location - About 45 mins to fix
nopasaran/machines/state_machine.py on lines 90..95

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

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

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

def set_TCP_automatic_packet_ack(ack_packet, original_packet):
    increase = 0
    if original_packet['TCP'].flags in ['S','F','SA','FA']:
        increase =  1
    elif original_packet['TCP'].flags in ['P','PA']:
Severity: Minor
Found in nopasaran/utils.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, right, rightsubnet, leftcert, leftid, rightid):
Severity: Minor
Found in nopasaran/ipsec_tunnels/ipsec_conf.py - About 35 mins to fix

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

        def dataReceived(self, encoded_json_data):
            """
            Handle received data.
            
            This method is called when data is received from the remote endpoint.
    Severity: Minor
    Found in nopasaran/controllers/protocol.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

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

        def get_conditions(self, possible_state):
            """
            Get the conditions for a possible state transition.
            
            Args:
    Severity: Minor
    Found in nopasaran/parsers/state_machine_parser.py and 1 other location - About 30 mins to fix
    nopasaran/parsers/state_machine_parser.py on lines 141..153

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

    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

    Avoid too many return statements within this function.
    Open

                return self.default(line, variable)
    Severity: Major
    Found in nopasaran/interpreters/interpreter.py - About 30 mins to fix

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

          def get_next_state_name(self, possible_state):
              """
              Get the name of the next state for a possible state transition.
              
              Args:
      Severity: Minor
      Found in nopasaran/parsers/state_machine_parser.py and 1 other location - About 30 mins to fix
      nopasaran/parsers/state_machine_parser.py on lines 127..139

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

      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

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

          def __filter_packet(self, packet):
              """
              Filter the packets.
              
              Args:
      Severity: Minor
      Found in nopasaran/sniffers/sniffer.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

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

          def wait_packet_signal(inputs, outputs, state_machine):
              """
              Wait for a packet to be available in the sniffer's packet stack stored in the machine's state.
              The sniffer's packet stack is created and populated in the 'listen' primitive.
              If a packet becomes available within the specified timeout (second mandatory input argument),
      Severity: Minor
      Found in nopasaran/primitives/action_primitives/data_channel_primitives.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

      Severity
      Category
      Status
      Source
      Language