cea-sec/miasm

View on GitHub
miasm/analysis/outofssa.py

Summary

Maintainability
F
3 days
Test Coverage

Function order_ssa_var_dom has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def order_ssa_var_dom(self):
        """Compute dominance order of each ssa variable"""
        ircfg = self.ssa.graph

        # compute dominator tree
Severity: Minor
Found in miasm/analysis/outofssa.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

File outofssa.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from future.utils import viewitems, viewvalues

from miasm.expression.expression import ExprId
from miasm.ir.ir import IRBlock, AssignBlock
from miasm.analysis.ssa import get_phi_sources_parent_block, \
Severity: Minor
Found in miasm/analysis/outofssa.py - About 3 hrs to fix

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

        def merge_sets_interfere(self, merge_a, merge_b, parent):
            """
            Return True if no variable in @merge_a and @merge_b interferes.
    
            Implementation of "Algorithm 2: Check intersection in a set of variables"
    Severity: Minor
    Found in miasm/analysis/outofssa.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

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

        def aggressive_coalesce_block(self):
            """Try to coalesce phi var with their pre/post variables"""
    
            ircfg = self.ssa.graph
    
    
    Severity: Minor
    Found in miasm/analysis/outofssa.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 isolate_phi_nodes_block has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def isolate_phi_nodes_block(self):
            """
            Init structures and virtually insert parallel copy before/after each phi
            node
            """
    Severity: Minor
    Found in miasm/analysis/outofssa.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 insert_parallel_copy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def insert_parallel_copy(self):
            """
            Naive Out-of-SSA from CSSA (without coalescing for now)
            - Replace Phi
            - Create room for parallel copies in Phi's parents
    Severity: Minor
    Found in miasm/analysis/outofssa.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 remove_assign_eq has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def remove_assign_eq(self):
            """
            Remove trivial expressions (a=a) in the current graph
            """
            for irblock in list(viewvalues(self.ssa.graph.blocks)):
    Severity: Minor
    Found in miasm/analysis/outofssa.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 ssa_def_is_live_at has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def ssa_def_is_live_at(self, node_a, node_b, parent):
            """
            Return True if @node_a is live during @node_b definition
            If @parent is None, this is a liveness test for a post phi variable;
            Else, it is a liveness test for a variable source of the phi node
    Severity: Minor
    Found in miasm/analysis/outofssa.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 (
                        # Is stack not empty?
                        dom and
                        # Trivial non-interference if dom.top() and current come
                        # from the same merge set
    Severity: Major
    Found in miasm/analysis/outofssa.py - About 40 mins to fix

      Function aggressive_coalesce_parallel_copy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def aggressive_coalesce_parallel_copy(self, parallel_copies, parent):
              """
              Try to coalesce variables each dst/src couple together from
              @parallel_copies
      
      
      Severity: Minor
      Found in miasm/analysis/outofssa.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 remove_phi has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_phi(self):
              """
              Remove phi operators in @ifcfg
              @ircfg: IRDiGraph instance
              """
      Severity: Minor
      Found in miasm/analysis/outofssa.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

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

                  for dst in irblock[0]:
                      new_var = self.phi_new_var[dst]
                      for parent, src in self.phi_parent_sources[dst]:
                          parent_to_parallel_copies.setdefault(parent, {})[new_var] = src
      Severity: Major
      Found in miasm/analysis/outofssa.py and 1 other location - About 2 hrs to fix
      miasm/analysis/outofssa.py on lines 82..85

      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 60.

      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

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

                  for dst in irblock[0]:
                      new_var = self.phi_new_var[dst]
                      for parent, src in self.phi_parent_sources[dst]:
                          parent_to_parallel_copies.setdefault(parent, {})[new_var] = src
      Severity: Major
      Found in miasm/analysis/outofssa.py and 1 other location - About 2 hrs to fix
      miasm/analysis/outofssa.py on lines 337..340

      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 60.

      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

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

      class Varinfo(object):
          """Store liveness information for a variable"""
          __slots__ = ["live_index", "loc_key", "index"]
      
          def __init__(self, live_index, loc_key, index):
      Severity: Major
      Found in miasm/analysis/outofssa.py and 1 other location - About 1 hr to fix
      miasm/analysis/ssa.py on lines 680..687

      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 46.

      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

      There are no issues that match your filters.

      Category
      Status