Showing 51 of 341 total issues
File test_functional.py
has 1346 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from copy import deepcopy
from flask import url_for
from sqlalchemy import and_
import datetime as dt
File views.py
has 633 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from io import BytesIO
from operator import itemgetter
import json
import datetime as dt
File models.py
has 443 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
import datetime as dt
import string
import uuid
File test_rules.py
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
import json
import logging
import datetime as dt
from collections import defaultdict
File utils.py
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from collections import namedtuple
from operator import itemgetter
from os.path import basename, join, splitext
import datetime as dt
Function enroll
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def enroll():
'''
Enroll an endpoint with osquery.
:returns: a `node_key` unique id. Additionally `node_invalid` will
- 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 search
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def search(page=1, max_pp=500):
try:
per_page = int(request.args.pop('pp', max_pp))
except Exception:
per_page = 20
- 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 api.py
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
from functools import wraps
from io import BytesIO
import datetime as dt
import gzip
Function parse_query
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def parse_query(self, query, alerters=None, rule_id=None):
"""
Parse a query output from jQuery.QueryBuilder.
"""
def parse_condition(d):
- 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 extract_results
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def extract_results(result):
"""
extract_results will convert the incoming log data into a series of Fields,
normalizing and/or aggregating both batch and event format into batch
format, which is used throughout the rest of doorman.
- 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_query_pack_from_upload
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def create_query_pack_from_upload(upload):
'''
Create a pack and queries from a query pack file. **Note**, if a
pack already exists under the filename being uploaded, then any
queries defined here will be added to the existing pack! However,
- 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 learn_from_result
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def learn_from_result(result, node):
if not result['data']:
return
capture_columns = set(
- 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 test_enroll_secret_tags
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_enroll_secret_tags(self, db, node, testapp):
testapp.app.config['DOORMAN_ENROLL_SECRET_TAG_DELIMITER'] = ':'
testapp.app.config['DOORMAN_EXPECTS_UNIQUE_HOST_ID'] = True
enroll_secret = testapp.app.config['DOORMAN_ENROLL_SECRET'][0]
resp = testapp.post_json(url_for('api.enroll'), {
Function __init__
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, name, query=None, sql=None, interval=3600, platform=None,
Function test_config
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_config(self):
node = NodeFactory(host_identifier='foo')
tag = Tag.create(value='foo')
node.tags.append(tag)
node.save()
Function distributed_write
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def distributed_write(node=None):
'''
'''
data = request.get_json()
- 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 test_configuration_has_all_required_values
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_configuration_has_all_required_values(self, node, testapp):
tag = TagFactory(value='foobar')
tag2 = TagFactory(value='barbaz')
pack = PackFactory(name='foobar')
pack.tags.append(tag)
Function __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, line=None, message=None, severity=None,
Function node_required
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def node_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
# in v1.7.4, the Content-Encoding header is set when
# --logger_tls_compress=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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate(self):
initial_validation = super(LoginForm, self).validate()
if not initial_validation:
return False
- 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"