Showing 32 of 54 total issues
Function resolve_itype
has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring. Open
def resolve_itype(indicator, test_broken=False):
def _ipv6(s):
try:
socket.inet_pton(socket.AF_INET6, s)
return True
- 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_timestamp
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def parse_timestamp(ts):
if isinstance(ts, arrow.Arrow):
return ts
t = human_to_dt(ts)
- 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 a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, indicator=None, version=PROTOCOL_VERSION, **kwargs):
self.version = version
if 'lowercase' in kwargs:
self._lowercase = kwargs.get('lowercase')
# indicate lowercase arg was explicitly passed by user rather than just a default value
- 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
Indicator
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Indicator(object):
def __init__(self, indicator=None, version=PROTOCOL_VERSION, **kwargs):
self.version = version
if 'lowercase' in kwargs:
Function __repr__
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def __repr__(self):
output = StringIO()
csvWriter = csv.DictWriter(output, self.cols, quoting=csv.QUOTE_ALL)
csvWriter.writeheader()
- 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 get_lines
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def get_lines(data, cols=COLUMNS, quoting=csv.QUOTE_ALL):
output = StringIO()
csvWriter = csv.DictWriter(output, cols, quoting=quoting)
csvWriter.writeheader()
- 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 _i_to_zeek
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def _i_to_zeek(i, cols):
if isinstance(i, Indicator):
i = i.__dict__()
cols = ['indicator', 'itype', 'description', 'tags', 'confidence', 'provider']
- 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 _create_indicator
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def _create_indicator(self, d):
def _hash(keypair, hash_type):
hash_type = 'TYPE_{}'.format(hash_type.upper())
h = Hash(keypair.get('indicator'), getattr(Hash, hash_type))
f = File()
- 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 _indicator_row
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def _indicator_row(i, cols, max_field_size):
if isinstance(i, Indicator):
i = i.__dict__()
r = []
- 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 __repr__
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def __repr__(self):
i = {}
for k in FIELDS:
v = getattr(self, k)
- 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
File indicator.py
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from pprint import pprint
import uuid
import logging
from .constants import PYVERSION, IPV4_PRIVATE_NETS, PROTOCOL_VERSION, FIELDS, FIELDS_TIME, LOG_FORMAT
Function format_keys
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def format_keys(self):
d = self.__dict__()
for k in d:
if PYVERSION == 2:
if not isinstance(d[k], unicode):
- 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 get_lines
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_lines(data, filename=OUTPUT_PATH):
output = StringIO()
text = [
";;; generated by: {} at {}".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
';RPZ DATA!',
- 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 get_lines
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_lines(data, filename=OUTPUT_PATH):
output = StringIO()
text = [
";;; generated by: {} at {}".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')),
';RPZ-IP DATA!',
- 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 normalize_indicator
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def normalize_indicator(i, itype=None, lowercase=False, lowercase_explicit=False):
if itype == 'fqdn':
i = i.rstrip('.')
# only don't lowercase if lowercase=False and lowercase_explicit=True (set by user)
if lowercase or not lowercase_explicit:
- 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 _indicator_row
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _indicator_row(i, cols):
if isinstance(i, Indicator):
i = i.__dict__()
r = dict()
- 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 indicator
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def indicator(self, i):
if not i:
self._indicator = None
return
- 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 deeply nested control flow statements. Open
if ',' in x:
tmp_list.extend([y.strip() for y in x.split(',') if y])
else:
tmp_list.append(x.strip())
kwargs[k] = tmp_list
Function get_lines
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_lines(data, filename=OUTPUT_PATH):
output = StringIO()
output.write("// generated by: {} at {}\n".format('csirtg-indicator', time.strftime('%Y-%m-%dT%H:%M:%S %Z')))
for i in data:
- 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 t