Konano/arknights-mower

View on GitHub
arknights_mower/utils/matcher.py

Summary

Maintainability
A
30 mins
Test Coverage

Function score has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Wontfix

    def score(self, query: tp.GrayImage, draw: bool = False, scope: tp.Scope = None, only_score: bool = False) -> Optional(Tuple[tp.Scope, tp.Score]):
        """ scoring of image matching """
        try:
            # if feature points is empty
            if self.des is None:
Severity: Minor
Found in arknights_mower/utils/matcher.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

Avoid too many return statements within this function.
Wontfix

                return rect, (good_matches_rate, good_area_rate, hash, ssim)
Severity: Major
Found in arknights_mower/utils/matcher.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Wontfix

                    return None
    Severity: Major
    Found in arknights_mower/utils/matcher.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Wontfix

                      return None
      Severity: Major
      Found in arknights_mower/utils/matcher.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Wontfix

                        return None
        Severity: Major
        Found in arknights_mower/utils/matcher.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return (good_matches_rate, good_area_rate, hash, ssim)
          Severity: Major
          Found in arknights_mower/utils/matcher.py - About 30 mins to fix

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

                def score(self, query: tp.GrayImage, draw: bool = False, scope: tp.Scope = None, only_score: bool = False) -> Optional(Tuple[tp.Scope, tp.Score]):
            Severity: Critical
            Found in arknights_mower/utils/matcher.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

            Rename function "getHash" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
            Wontfix

            def getHash(data: list[float]) -> tp.Hash:

            Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

            Noncompliant Code Example

            With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

            def MyFunction(a,b):
                ...
            

            Compliant Solution

            def my_function(a,b):
                ...
            

            Rename function "aHash" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
            Wontfix

            def aHash(img1: tp.GrayImage, img2: tp.GrayImage) -> int:

            Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

            Noncompliant Code Example

            With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

            def MyFunction(a,b):
                ...
            

            Compliant Solution

            def my_function(a,b):
                ...
            

            Rename function "hammingDistance" to match the regular expression ^[a-z_][a-z0-9_]{2,}$.
            Wontfix

            def hammingDistance(hash1: tp.Hash, hash2: tp.Hash) -> int:

            Shared coding conventions allow teams to collaborate efficiently. This rule checks that all function names match a provided regular expression.

            Noncompliant Code Example

            With the default provided regular expression: ^[a-z_][a-z0-9_]{2,30}$

            def MyFunction(a,b):
                ...
            

            Compliant Solution

            def my_function(a,b):
                ...
            

            There are no issues that match your filters.

            Category
            Status