python-security/pyt

View on GitHub

Showing 158 of 158 total issues

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

    def append_if_local_or_in_imports(self, definition):
        """Add definition to list.

        Handles local definitions and adds to project_definitions.
        """
Severity: Minor
Found in pyt/core/module_definitions.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if node.module not in uninspectable_modules:
            log.warning("Cannot inspect module %s", node.module)
            uninspectable_modules.add(node.module)
Severity: Minor
Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
pyt/cfg/stmt_visitor.py on lines 1067..1069

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 35.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def __init__(self, label, left_hand_side, right_hand_side_variables, *, line_number, path):
Severity: Minor
Found in pyt/core/node_types.py - About 45 mins to fix

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

    def generate_ast(path):
        """Generate an Abstract Syntax Tree using the ast module.
    
            Args:
                path(str): The path to the file e.g. example/foo/bar.py
    Severity: Minor
    Found in pyt/core/ast_helper.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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                    return self.add_module(
                        module=module,
                        module_or_package_name=None,
                        local_names=as_alias_handler(node.names),
                        import_alias_mapping=retrieve_import_alias_mapping(node.names),
    Severity: Minor
    Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
    pyt/cfg/stmt_visitor.py on lines 1085..1089

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 35.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        def __init__(
    Severity: Minor
    Found in pyt/core/node_types.py - About 45 mins to fix

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          def visit_SetComp(self, node):
              self.visit(node.elt)
              for gen in node.generators:
                  self.comprehension(gen)
      Severity: Major
      Found in pyt/helper_visitors/vars_visitor.py and 3 other locations - About 45 mins to fix
      pyt/helper_visitors/vars_visitor.py on lines 50..53
      pyt/helper_visitors/vars_visitor.py on lines 66..69
      pyt/helper_visitors/vars_visitor.py on lines 78..81

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

          def visit_Compare(self, node):
              self.visit(node.left)
              for c in node.comparators:
                  self.visit(c)
      Severity: Major
      Found in pyt/helper_visitors/vars_visitor.py and 3 other locations - About 45 mins to fix
      pyt/helper_visitors/vars_visitor.py on lines 50..53
      pyt/helper_visitors/vars_visitor.py on lines 55..58
      pyt/helper_visitors/vars_visitor.py on lines 66..69

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 35.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          def __init__(
      Severity: Minor
      Found in pyt/cfg/expr_visitor.py - About 45 mins to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                        return self.add_module(
                            module=module,
                            module_or_package_name=None,
                            local_names=as_alias_handler(node.names),
                            import_alias_mapping=retrieve_import_alias_mapping(node.names),
        Severity: Minor
        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
        pyt/cfg/stmt_visitor.py on lines 1102..1106

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            def visit_GeneratorComp(self, node):
                self.visit(node.elt)
                for gen in node.generators:
                    self.comprehension(gen)
        Severity: Major
        Found in pyt/helper_visitors/vars_visitor.py and 3 other locations - About 45 mins to fix
        pyt/helper_visitors/vars_visitor.py on lines 50..53
        pyt/helper_visitors/vars_visitor.py on lines 55..58
        pyt/helper_visitors/vars_visitor.py on lines 78..81

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    if alias.name not in uninspectable_modules:
                        log.warning("Cannot inspect module %s", alias.name)
                        uninspectable_modules.add(alias.name)  # Don't repeatedly warn about this
        Severity: Minor
        Found in pyt/cfg/stmt_visitor.py and 1 other location - About 45 mins to fix
        pyt/cfg/stmt_visitor.py on lines 1117..1119

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Avoid deeply nested control flow statements.
        Open

                            if file.endswith('.py') and file not in excluded_list:
                                fullpath = os.path.join(root, file)
                                included_files.append(fullpath)
                                log.debug('Discovered file: %s', fullpath)
                        if not recursive:
        Severity: Major
        Found in pyt/__main__.py - About 45 mins to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              def visit_ListComp(self, node):
                  self.result += '['
                  self.comprehensions(node)
                  self.result += ']'
          Severity: Major
          Found in pyt/helper_visitors/label_visitor.py and 2 other locations - About 40 mins to fix
          pyt/helper_visitors/label_visitor.py on lines 109..112
          pyt/helper_visitors/label_visitor.py on lines 119..122

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 34.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              def visit_SetComp(self, node):
                  self.result += '{'
                  self.comprehensions(node)
                  self.result += '}'
          Severity: Major
          Found in pyt/helper_visitors/label_visitor.py and 2 other locations - About 40 mins to fix
          pyt/helper_visitors/label_visitor.py on lines 109..112
          pyt/helper_visitors/label_visitor.py on lines 114..117

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 34.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              def visit_GeneratorExp(self, node):
                  self.result += '('
                  self.comprehensions(node)
                  self.result += ')'
          Severity: Major
          Found in pyt/helper_visitors/label_visitor.py and 2 other locations - About 40 mins to fix
          pyt/helper_visitors/label_visitor.py on lines 114..117
          pyt/helper_visitors/label_visitor.py on lines 119..122

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 34.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          def find_vulnerabilities(
          Severity: Minor
          Found in pyt/vulnerabilities/vulnerabilities.py - About 35 mins to fix

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

                def __init__(
            Severity: Minor
            Found in pyt/vulnerabilities/trigger_definitions_parser.py - About 35 mins to fix

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

                  def __init__(
              Severity: Minor
              Found in pyt/vulnerabilities/vulnerability_helper.py - About 35 mins to fix

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

                    def save_def_args_in_temp(
                Severity: Minor
                Found in pyt/cfg/expr_visitor.py - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language