derwentx/Xero-Map-Generator

View on GitHub

Showing 13 of 13 total issues

Function get_map_contacts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def get_map_contacts(conf):
    xero = XeroApiWrapper(**dict(conf.XeroApiConfig))
    map_contact_groups = conf.FilterConfig.get('contact_groups', '').split('|')
    PKG_LOGGER.debug("map contact groups: %s", map_contact_groups)
    contact_limit = conf.BaseConfig.contact_limit or None
Severity: Minor
Found in xero_map_gen/core.py - About 2 hrs 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

File contain.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python2
"""Container classes and utilities for containing data."""

import csv
import heapq
Severity: Minor
Found in xero_map_gen/contain.py - About 2 hrs to fix

    Function get_contacts_by_ids has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_contacts_by_ids(self, contact_ids, limit=None, chunk_size=20):
            # TODO: local caching and check modified time
            limit = limit or None
            total = len(contact_ids)
            if limit is not None:
    Severity: Minor
    Found in xero_map_gen/transport.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 setup_logging has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def setup_logging(stream_log_level=None, log_path=None, file_log_level=None, **kwargs):
        global PKG_FILE_HANDLER, PKG_STREAM_HANDLER
    
        if log_path:
            if PKG_FILE_HANDLER:
    Severity: Minor
    Found in xero_map_gen/log.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 _primary_property has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _primary_property(
                self, properties, type_key, type_priority, fn_empty, default=None):
            """ Abstract main_address and main_phone. """
            if not properties:
                return default
    Severity: Minor
    Found in xero_map_gen/contain.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 _primary_property has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _primary_property(
    Severity: Minor
    Found in xero_map_gen/contain.py - About 35 mins to fix

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

          def __init__(self, aliases=None, flags=None, *super_args, **super_kwargs):
              """
              Create Rich KVArgParseConfigLoader object.
      
              Parameters
      Severity: Minor
      Found in xero_map_gen/rich_traitlets.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 dump_items_csv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def dump_items_csv(cls, items, dump_path='items.csv', names=None, flatten_attr=None):
              try:
                  with open(dump_path, 'w'):
                      pass
              except IOError as exc:
      Severity: Minor
      Found in xero_map_gen/contain.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 _get_contact_ids_in_group_ids has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_contact_ids_in_group_ids(
                  self, contact_group_ids=None, limit=None):
              contact_ids = set()
              for contact_group_id in contact_group_ids:
                  group_data = self.rate_limit_retry_query(
      Severity: Minor
      Found in xero_map_gen/transport.py - About 25 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 load_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def load_config(argv=None, proto_config=None):
          """
          Successively merge config files from different sources, overriding the previous.
      
          Config merge order:
      Severity: Minor
      Found in xero_map_gen/config.py - About 25 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

      Either remove or fill this block of code.
      Open

                      pass
      Severity: Major
      Found in xero_map_gen/contain.py by sonar-python

      Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

      Noncompliant Code Example

      for i in range(3):
          pass
      

      Exceptions

      When a block contains a comment, this block is not considered to be empty.

      Remove this commented out code.
      Open

                  # thing = thing.decode('ascii', errors=errors)
      Severity: Major
      Found in xero_map_gen/helper.py by sonar-python

      Programmers should not comment out code as it bloats programs and reduces readability.

      Unused code should be deleted and can be retrieved from source control history if required.

      See

      • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
      • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
      • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
      • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

      Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed.
      Open

      def get_map_contacts(conf):
      Severity: Critical
      Found in xero_map_gen/core.py by sonar-python

      Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

      See

      Severity
      Category
      Status
      Source
      Language