Showing 18 of 89 total issues
File dns_primitives.py
has 459 lines of code (exceeds 250 allowed). Consider refactoring. Open
from scapy.all import IP, UDP, DNS, DNSQR, DNSRR
from nopasaran.decorators import parsing_decorator
class DNSPrimitives:
DNSPrimitives
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class DNSPrimitives:
"""
Class containing DNS action primitives for the state machine.
"""
Function parsing_decorator
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def parsing_decorator(input_args, output_args, optional_inputs=False, optional_outputs=False):
"""
Decorator for parsing inputs and outputs of a function.
This decorator parses the inputs and outputs of a function based on the specified constraints.
- Read upRead up
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_sync_signal
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def wait_sync_signal(inputs, outputs, state_machine):
"""
Wait for a synchronization message to be available in the controller protocol's queue.
If a message becomes available within the specified timeout (input argument),
store its contents in the output variables and trigger the event SYNC_AVAILABLE.
- Read upRead up
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 parse
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def parse(command, input_args, output_args, optional_inputs=False, optional_outputs=False):
"""
Parse the command and validate the arguments.
This method parses the command and validates the number of input and output arguments
- Read upRead up
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_ready_signal
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def wait_ready_signal(inputs, outputs, state_machine):
"""
Wait for the local and remote status of the controller protocol to be READY.
If the status becomes READY within the specified timeout (input argument),
triggers the event READY. Otherwise, triggers the event TIMEOUT.
- Read upRead up
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 onecmd
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def onecmd(self, line, variable):
"""
Run a single command with the provided line and variable.
Args:
- Read upRead up
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 main
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def main():
# Set up argument parser
parser = argparse.ArgumentParser(
prog='ROLE',
description='NoPASARAN: Internet Route Testing Framework for Network Middleboxes',
- Read upRead up
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 _check_validity
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _check_validity(string):
"""
Check the validity of the string.
This method checks whether the string has valid parentheses.
- Read upRead up
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 configure_ipsec
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def configure_ipsec(self, controller_section, left='', leftsubnet='', right='', rightsubnet='', leftcert='', leftid='', rightid=''):
Function make_transition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def make_transition(self, possible_states):
"""
Make a state transition.
Args:
- Read upRead up
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 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']:
- Read upRead up
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 set_TCP_automatic_packet_seq
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_TCP_automatic_packet_seq(packet):
increase = 0
if packet['TCP'].flags in ['S','F','SA','FA']:
increase = 1
elif packet['TCP'].flags in ['P','PA']:
- Read upRead up
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):
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.
- Read upRead up
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 self.default(line, variable)
Function __filter_packet
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __filter_packet(self, packet):
"""
Filter the packets.
Args:
- Read upRead up
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),
- Read upRead up
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"