Javakky/NicoApiClient

View on GitHub
nicovideo_api_client/api/v2/targets.py

Summary

Maintainability
A
2 hrs
Test Coverage

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

    def and_(self, keyword: Union[str, list[str]]) -> "SnapshotSearchAPIV2And":
        """
        AND 検索に利用する。
        NOT 検索に必要なパラメータは `query()` で指定する。
        :param keyword: 検索するキーワード。文字列または文字列を要素に持つリスト。リストにする場合は OR で連結される。
Severity: Minor
Found in nicovideo_api_client/api/v2/targets.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 (
            ((keyword[0] != '"' and keyword[-1] != '"') and " " in keyword)
            or keyword[0] == "-"
            or '"' in keyword
            or "\\" in keyword
Severity: Major
Found in nicovideo_api_client/api/v2/targets.py - About 40 mins to fix

    Function _arrange_keyword has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def _arrange_keyword(self, keyword: str, exclude: bool = False):
            """
            キーワードを適切な形でクエリに指定する。
            :param keyword: クエリのqキーに指定するための文字列
            """
    Severity: Minor
    Found in nicovideo_api_client/api/v2/targets.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

    There are no issues that match your filters.

    Category
    Status