cea-sec/miasm

View on GitHub
miasm/analysis/modularintervals.py

Summary

Maintainability
F
3 days
Test Coverage

File modularintervals.py has 428 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Intervals with a maximum size, supporting modular arithmetic"""

from future.builtins import range
from builtins import int as int_types
from itertools import product
Severity: Minor
Found in miasm/analysis/modularintervals.py - About 6 hrs to fix

    ModularIntervals has 43 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ModularIntervals(object):
        """Intervals with a maximum size, supporting modular arithmetic"""
    
        def __init__(self, size, intervals=None):
            """Instantiate a ModularIntervals of size @size
    Severity: Minor
    Found in miasm/analysis/modularintervals.py - About 5 hrs to fix

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

          def _range_or_min(self, x_min, x_max, y_min, y_max):
              """Interval min for x | y, with
               - x, y of size self.size
               - @x_min <= x <= @x_max
               - @y_min <= y <= @y_max
      Severity: Minor
      Found in miasm/analysis/modularintervals.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 _range_and_max has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _range_and_max(self, x_min, x_max, y_min, y_max):
              """Interval max for x & y, with
               - x, y of size self.size
               - @x_min <= x <= @x_max
               - @y_min <= y <= @y_max
      Severity: Minor
      Found in miasm/analysis/modularintervals.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 _range_or_max has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _range_or_max(self, x_min, x_max, y_min, y_max):
              """Interval max for x | y, with
               - x, y of size self.size
               - @x_min <= x <= @x_max
               - @y_min <= y <= @y_max
      Severity: Minor
      Found in miasm/analysis/modularintervals.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 _range_and_min has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def _range_and_min(self, x_min, x_max, y_min, y_max):
              """Interval min for x & y, with
               - x, y of size self.size
               - @x_min <= x <= @x_max
               - @y_min <= y <= @y_max
      Severity: Minor
      Found in miasm/analysis/modularintervals.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 _range_shift_uniq has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _range_shift_uniq(self, x_min, x_max, shift, op):
              """Bounds interval for x @op @shift with
               - x of size self.size
               - @x_min <= x <= @x_max
               - operations are considered unsigned
      Severity: Minor
      Found in miasm/analysis/modularintervals.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 _interval_shift has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _interval_shift(self, operation, shifter):
              """Apply the shifting operation @operation with a shifting
              ModularIntervals @shifter on the current instance"""
              # Work on a copy of shifter intervals
              shifter = interval(shifter.intervals)
      Severity: Minor
      Found in miasm/analysis/modularintervals.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 _interval_rotate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _interval_rotate(self, operation, shifter):
              """Apply the rotate operation @operation with a shifting
              ModularIntervals @shifter on the current instance"""
              # Consider only rotation without repetition, and enumerate
              # -> apply a '% size' on shifter
      Severity: Minor
      Found in miasm/analysis/modularintervals.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 _promote has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _promote(func):
              """Check and promote the second argument from integer to
              ModularIntervals with one value"""
              def ret_func(self, target):
                  if isinstance(target, int_types):
      Severity: Minor
      Found in miasm/analysis/modularintervals.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

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

              for shift_range in shifter:
                  for shift in range(shift_range[0], shift_range[1] + 1):
                      for x_min, x_max in self.intervals:
                          ret += self._range_rotate_uniq(x_min, x_max, shift,
                                                         operation)
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 3 hrs to fix
      miasm/analysis/modularintervals.py on lines 336..339

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

      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

              for shift_range in shifter:
                  for shift in range(shift_range[0], shift_range[1] + 1):
                      for x_min, x_max in self.intervals:
                          ret += self._range_shift_uniq(x_min, x_max, shift, operation)
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 3 hrs to fix
      miasm/analysis/modularintervals.py on lines 372..376

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

      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 x_max & ~y_max & max_bit:
                      temp = (x_max & ~max_bit) | (max_bit - 1)
                      if temp >= x_min:
                          x_max = temp
                          break
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 1 hr to fix
      miasm/analysis/modularintervals.py on lines 223..227

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

      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

                  elif ~x_max & y_max & max_bit:
                      temp = (y_max & ~max_bit) | (max_bit - 1)
                      if temp >= y_min:
                          y_max = temp
                          break
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 1 hr to fix
      miasm/analysis/modularintervals.py on lines 218..222

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

      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

          def _range_and(self, x_min, x_max, y_min, y_max):
              """Interval bounds for x & y, with
               - x, y of size @size
               - @x_min <= x <= @x_max
               - @y_min <= y <= @y_max
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 1 hr to fix
      miasm/analysis/modularintervals.py on lines 173..182

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

      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

          def _range_or(self, x_min, x_max, y_min, y_max):
              """Interval bounds for x | y, with
               - x, y of size self.size
               - @x_min <= x <= @x_max
               - @y_min <= y <= @y_max
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 1 hr to fix
      miasm/analysis/modularintervals.py on lines 231..240

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

      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

                  elif x_min & ~y_min & max_bit:
                      temp = (y_min | max_bit) & - max_bit
                      if temp <= y_max:
                          y_min = temp
                          break
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 1 hr to fix
      miasm/analysis/modularintervals.py on lines 138..142

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

      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 ~x_min & y_min & max_bit:
                      temp = (x_min | max_bit) & - max_bit
                      if temp <= x_max:
                          x_min = temp
                          break
      Severity: Major
      Found in miasm/analysis/modularintervals.py and 1 other location - About 1 hr to fix
      miasm/analysis/modularintervals.py on lines 143..147

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

      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