mwielgoszewski/doorman

View on GitHub

Showing 51 of 341 total issues

Function add_distributed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def add_distributed():
    form = AddDistributedQueryForm()
    form.set_choices()

    if form.validate_on_submit():
Severity: Minor
Found in doorman/manage/views.py - About 1 hr 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 logger has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def logger(node=None):
    '''
    '''
    data = request.get_json()
    log_type = data['log_type']
Severity: Minor
Found in doorman/api.py - About 1 hr 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 create_tags has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def create_tags(*tags):
    values = []
    existing = []

    # create a set, because we haven't yet done our association_proxy in
Severity: Minor
Found in doorman/manage/views.py - About 1 hr 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 get_paginate_options has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def get_paginate_options(request, model, choices, existing_query=None,
Severity: Major
Found in doorman/utils.py - About 1 hr to fix

    Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, host_identifier, node_key=None,
    Severity: Major
    Found in doorman/models.py - About 1 hr to fix

      Function quote has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def quote(s, quote='"'):
          buf = [quote]
          for ch in s:
              if ch == quote or ch == '\\':
                  buf.append('\\')
      Severity: Minor
      Found in doorman/utils.py - About 55 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 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, name=None, action=None, columns=None, timestamp=None,
      Severity: Major
      Found in doorman/models.py - About 50 mins to fix

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

        def tags():
            tags = dict((t.value, {}) for t in Tag.query.all())
        
            if request.is_xhr:
                return jsonify(tags=tags.keys())
        Severity: Minor
        Found in doorman/manage/views.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 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, username, password=None, email=None, social_id=None,
        Severity: Minor
        Found in doorman/models.py - About 45 mins to fix

          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, name, platform=None, version=None,
          Severity: Minor
          Found in doorman/models.py - About 45 mins to fix

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

                def load_rules(self):
                    """ Load rules from the database. """
                    from doorman.rules import Network
                    from doorman.models import Rule
            
            
            Severity: Minor
            Found in doorman/extensions.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 distributed_results has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def distributed_results(distributed_id, status=None, page=1):
                query = DistributedQuery.query.filter_by(id=distributed_id).first_or_404()
                tasks = DistributedQueryTask.query.filter_by(distributed_query_id=query.id)
            
                if status == 'new':
            Severity: Minor
            Found in doorman/manage/views.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 query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def query(query_id):
                query = Query.query.filter(Query.id == query_id).first_or_404()
                form = UpdateQueryForm(request.form)
            
                if form.validate_on_submit():
            Severity: Minor
            Found in doorman/manage/views.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

            Consider simplifying this complex logical expression.
            Open

                        if action == 'removed' and (cvalue is None or cvalue != value):
                            pass
                        elif action == 'removed' and cvalue == value:
                            node_info.pop(column)
                        elif action == 'added' and (cvalue is None or cvalue != value):
            Severity: Major
            Found in doorman/utils.py - About 40 mins to fix

              Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, name, alerters, description=None, conditions=None, updated_at=None):
              Severity: Minor
              Found in doorman/models.py - About 35 mins to fix

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

                    def handle_result(self, data, **kwargs):
                        if self.result is None:
                            return
                
                        # Process each result individually
                Severity: Minor
                Found in doorman/plugins/logs/file.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

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

                    def fetch_user(self):
                        code = request.args.get('code')
                        state = session.pop('_oauth_state')
                
                        provider = OAuth2Session(
                Severity: Minor
                Found in doorman/users/oauth.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

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

                    def make_condition(self, klass, *args, **kwargs):
                        """
                        Memoizing constructor for conditions.  Uses the input config as the cache key.
                        """
                        # Calculate the memoization key.  We do this by creating a 3-tuple of
                Severity: Minor
                Found in doorman/rules.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

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

                def nodes(page=1, status='active'):
                    if status == 'inactive':
                        nodes = Node.query.filter_by(is_active=False)
                    else:
                        nodes = Node.query.filter_by(is_active=True)
                Severity: Minor
                Found in doorman/manage/views.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

                Avoid too many return statements within this function.
                Open

                                return obj
                Severity: Major
                Found in doorman/rules.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language