Showing 56 of 172 total issues
File indicator.py
has 558 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os
import arrow
import json
from base64 import b64encode
import ipaddress
Function _filter_terms
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def _filter_terms(self, filters, s):
idx = ['reported_at', 'itype', 'confidence', 'probability', 'provider', 'asn', 'cc', 'asn_desc',
'rdata', 'region', 'uuid', 'tags']
- 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 __init__.py
has 404 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
import logging
import textwrap
import ujson as json
Function _upsert
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def _upsert(self, s, n, d, token, cached_added, batch):
try:
# check to see if it's been added in the cache
if cached_added.get(d['indicator']):
if d.get('last_at') in cached_added[d['indicator']]:
- 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 start
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def start(self):
self.context = zmq.Context()
self.router = self.context.socket(zmq.ROUTER)
self.router_write = self.context.socket(zmq.ROUTER)
self.router_write_h = self.context.socket(zmq.ROUTER)
- 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 process
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def process(i):
if not ENABLED:
return
if not i.is_fqdn():
- 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 router.py
has 307 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
import ujson as json
import logging
import textwrap
Function _pull_feed
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def _pull_feed(self, filters, agg=True):
if agg and not filters.get('reported_at') and not filters.get('days') \
and not filters.get('hours'):
if not filters.get('itype'):
filters['days'] = str(DAYS_SHORT)
- 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 firehose
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def firehose(ws):
"""Firehose"""
t = pull_token()
- 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 handle_message
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def handle_message(self, m):
err = None
id, client_id, token, mtype, data = m
try:
- 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 17 (exceeds 5 allowed). Consider refactoring. Open
def main():
p = get_argument_parser()
p = ArgumentParser(
description=textwrap.dedent('''\
Env Variables:
- 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 post
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def post(self):
"""Create an Indicator"""
if len(request.data) == 0:
return 'missing indicator', 422
- 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
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get(self):
"""List all indicators"""
filters = self._filters_cleanup()
logger.debug(filters)
- 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 _filter_indicator
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def _filter_indicator(self, filters, s):
for k, v in list(filters.items()):
if k not in VALID_FILTERS:
del filters[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
Function _flush_create_queue
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _flush_create_queue(self):
for t in self.create_queue:
if len(self.create_queue[t]['messages']) == 0:
continue
- 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 _upsert_filter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _upsert_filter(self, s, d, tags):
# setup query
i = s.query(Indicator).options(lazyload('*')).filter_by(
provider=d['provider'],
itype=d['itype'],
- 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 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self, **kwargs):
self.uuid = kwargs.get('uuid')
self.indicator = kwargs.get('indicator')
self.group = kwargs.get('group', 'everyone')
Function handle_message_gatherer
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def handle_message_gatherer(self, s):
id, token, mtype, data = Msg().recv(s)
sock = self.store.s_write
if token == self.hunter_token:
- 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 _upsert_itype
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _upsert_itype(self, s, i):
if i.itype == 'ipv4':
match = re.search('^(\S+)\/(\d+)$', i.indicator) # TODO -- use ipaddress
if match:
ipv4 = Ipv4(ipv4=match.group(1), mask=match.group(2), indicator=i)
- 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 process
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process(self, data):
if isinstance(data, dict):
data = [data]
s = time()
- 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"