christoph2/pyA2L

View on GitHub

Showing 21 of 238 total issues

A2LListener has 193 functions (exceeds 80 allowed). Consider refactoring.
Open

class A2LListener(BaseListener):
    """"""

    def exitAlignmentByte(self, ctx):
        alignmentBorder = ctx.alignmentBorder.value
Severity: Major
Found in pya2l/a2l_listener.py - About 2 days to fix

    File inspect.py has 2956 lines of code (exceeds 2500 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    __copyright__ = """
        pySART - Simplified AUTOSAR-Toolkit for Python.
    Severity: Major
    Found in pya2l/api/inspect.py - About 1 day to fix

      Function __init__ has a Cognitive Complexity of 49 (exceeds 15 allowed). Consider refactoring.
      Open

          def __init__(self, session, name: str, module_name: str = None):
              self.compu_method = session.query(model.CompuMethod).filter(model.CompuMethod.name == name).first()
              if not self.compu_method:
                  return
              self.name = name
      Severity: Minor
      Found in pya2l/api/inspect.py - About 5 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

      Function _process_file has a Cognitive Complexity of 45 (exceeds 15 allowed). Consider refactoring.
      Open

          def _process_file(self, file_name, join_lines=True, encoding="latin-1"):
              result = []
              start_line_number = self.absolute_file_number + 1
              multiline = False
              pth_obj = Path(file_name)
      Severity: Minor
      Found in pya2l/preprocessor.py - About 5 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

      Function _process_aml has a Cognitive Complexity of 39 (exceeds 15 allowed). Consider refactoring.
      Open

          def _process_aml(self, data):
              """Extract A2ML and IF_DATA sections."""
              result = []
              sections = []
              aml_section = []
      Severity: Minor
      Found in pya2l/preprocessor.py - About 4 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

      Function tagged_struct has a Cognitive Complexity of 38 (exceeds 15 allowed). Consider refactoring.
      Open

          def tagged_struct(self):
              self.enter("tagged_struct")
              tag = self.block_or_tag()
              tags = self.current_element.tags.keys()
              counter = {k: False for k in tags}
      Severity: Minor
      Found in pya2l/if_data_parser.py - About 4 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

      Function __init__ has a Cognitive Complexity of 25 (exceeds 15 allowed). Consider refactoring.
      Open

          def __init__(self, parent, items: dict, alignment: dict):
              self.parent = parent
              self.alignment = alignment
              result = []
              positions = {}
      Severity: Minor
      Found in pya2l/api/inspect.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 import_a2l has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def import_a2l(
      Severity: Major
      Found in pya2l/__init__.py - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if match:
                                    s, e = match.span()
                                    if_data_end = (line_num, e - len(match.group("tail")))
                                    if_data_section.append("{}/end{}IF_DATA".format(match.group("section"), match.group("s0")))
                                    section = (
        Severity: Major
        Found in pya2l/preprocessor.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if definition.multiple:
                                      tag_dict[tag].append(value)
                                  else:
                                      tag_dict[tag] = value
                                  self.pop_element()
          Severity: Major
          Found in pya2l/if_data_parser.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if ((self.current_token.type != self.lexer.IDENT) or (self.current_token.text not in tags)) and (
                                        self.current_token.type != self.lexer.BEGIN
                                    ):
                                        break
                                else:
            Severity: Major
            Found in pya2l/if_data_parser.py - About 45 mins to fix

              Function __init__ has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
              Open

                  def __init__(self, session, module_name: str = None):
                      self.variantCoding = session.query(model.VariantCoding).first()
                      self._naming = self.variantCoding.var_naming.tag if self.variantCoding.var_naming else "NUMERIC"
                      self._separator = self.variantCoding.var_separator.separator if self.variantCoding.var_separator else "."
              
              
              Severity: Minor
              Found in pya2l/api/inspect.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 syntaxError has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e):
              Severity: Minor
              Found in pya2l/parserlib.py - About 45 mins to fix

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

                def doTemplateFromText(
                Severity: Minor
                Found in pya2l/templates.py - About 45 mins to fix

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

                  def doTemplate(
                  Severity: Minor
                  Found in pya2l/templates.py - About 45 mins to fix

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

                        def __init__(self, session, name=None, module_name: str = None, parent=None, *args):
                    Severity: Minor
                    Found in pya2l/api/inspect.py - About 35 mins to fix

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

                          def __init__(
                      Severity: Minor
                      Found in pya2l/parserlib.py - About 35 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return None
                        Severity: Major
                        Found in pya2l/api/inspect.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return iterable[0]
                          Severity: Major
                          Found in pya2l/a2l_listener.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return [iterable[0]]
                            Severity: Major
                            Found in pya2l/a2l_listener.py - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language