bitcoin/bitcoin

View on GitHub

Showing 80 of 84 total issues

Function parse_gpg_result has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def parse_gpg_result(
    output: list[str]
) -> tuple[list[SigData], list[SigData], list[SigData]]:
    """Returns good, unknown, and bad signatures from GPG stdout."""
    good_sigs: list[SigData] = []
Severity: Minor
Found in contrib/verify-binaries/verify.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

File symbol-check.py has 254 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# Copyright (c) 2014 Wladimir J. van der Laan
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
'''
Severity: Minor
Found in contrib/devtools/symbol-check.py - About 2 hrs to fix

    Function to_jsonable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def to_jsonable(obj: Any) -> Any:
        if hasattr(obj, "__dict__"):
            return obj.__dict__
        elif hasattr(obj, "__slots__"):
            ret = {}    # type: Any
    Severity: Minor
    Found in contrib/message-capture/message-capture-parser.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 _from_binnode has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def _from_binnode(binnode: _BinNode) -> "ASMap":
            """Construct an ASMap object from a _BinNode. Internal use only."""
            def recurse(node: _BinNode, default: int) -> list:
                if node.ins == _Instruction.RETURN:
                    return [node.arg1]
    Severity: Minor
    Found in contrib/seeds/asmap.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 parse_po has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_po(text):
        """
        Parse 'po' format produced by xgettext.
        Return a list of (msgid,msgstr) tuples.
        """
    Severity: Minor
    Found in share/qt/extract_strings_qt.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 parse_makefile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_makefile(makefile):
        with open(makefile, 'r', encoding='utf-8') as file:
            current_lib = ''
            for line in file.read().splitlines():
                if current_lib:
    Severity: Minor
    Found in build_msvc/msvc-autogen.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 check_imported_symbols has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_imported_symbols(binary) -> bool:
        ok: bool = True
    
        for symbol in binary.imported_symbols:
            if not symbol.imported:
    Severity: Minor
    Found in contrib/devtools/symbol-check.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 check_ELF_separate_code has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_ELF_separate_code(binary):
        '''
        Check that sections are appropriately separated in virtual memory,
        based on their permissions. This checks for missing -Wl,-z,separate-code
        and potentially other problems.
    Severity: Minor
    Found in contrib/devtools/security-check.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 render has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def render(screen, peers, cur_list_pos, scroll, ROWS_AVALIABLE_FOR_LIST, info_panel):
        """ renders the list of peers and details panel
    
        This code is unrelated to USDT, BCC and BPF.
        """
    Severity: Minor
    Found in contrib/tracing/p2p_monitor.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 get_block_hashes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_block_hashes(settings, max_blocks_per_call=10000):
        rpc = BitcoinRPC(settings['host'], settings['port'],
                 settings['rpcuser'], settings['rpcpassword'])
    
        height = settings['min_height']
    Severity: Minor
    Found in contrib/linearize/linearize-hashes.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 _to_entries_flat has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def _to_entries_flat(self, fill: bool = False) -> list[ASNEntry]:
            """Convert an ASMap object to a list of non-overlapping (prefix, asn) objects."""
            prefix : list[bool] = []
    
            def recurse(node: list) -> list[ASNEntry]:
    Severity: Minor
    Found in contrib/seeds/asmap.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 print_report has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def print_report(file_infos, verbose):
        print(SEPARATOR)
        examined = [i['filename'] for i in file_infos]
        print("%d files examined according to INCLUDE and EXCLUDE fnmatch rules" %
              len(examined))
    Severity: Minor
    Found in contrib/devtools/copyright_header.py - About 1 hr to fix

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

      def optimize(when):
          """Find the best (period, bufsize) configuration."""
      
          # When period*bufsize = memory_scale, the per-peer memory for a mainchain sync and a maximally
          # long low-difficulty header sync are equal.
      Severity: Minor
      Found in contrib/devtools/headerssync-params.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 gen_invalid_bech32_vector has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def gen_invalid_bech32_vector(template):
          '''Generate possibly invalid bech32 vector'''
          no_data = randbool(0.1)
          to_upper = randbool(0.1)
          hrp = template[0]
      Severity: Minor
      Found in contrib/testgen/gen_key_io_test_vectors.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 main has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def main():
          args = parse_args()
      
          print(f'Loading asmap database "{args.asmap}"…', end='', file=sys.stderr, flush=True)
          with open(args.asmap, 'rb') as f:
      Severity: Minor
      Found in contrib/seeds/makeseeds.py - About 1 hr to fix

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

            def test_asmap_roundtrips(self) -> None:
                """Test case that verifies random ASMap objects roundtrip to/from entries/binary."""
                # Iterate over the number of leaves the random test ASMap objects have.
                for leaves in range(1, 20):
                    # Iterate over the number of bits in the AS numbers used.
        Severity: Minor
        Found in contrib/seeds/asmap.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 gen_invalid_base58_vector has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def gen_invalid_base58_vector(template):
            '''Generate possibly invalid vector'''
            # kinds of invalid vectors:
            #   invalid prefix
            #   invalid payload length
        Severity: Minor
        Found in contrib/testgen/gen_key_io_test_vectors.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 _set_trie has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _set_trie(self, trie) -> None:
                """Set trie directly. Internal use only."""
                def recurse(node: list) -> None:
                    if len(node) < 2:
                        return
        Severity: Minor
        Found in contrib/seeds/asmap.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 extends has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def extends(self, req: "ASMap") -> bool:
                """Determine whether this matches req for all subranges where req is assigned."""
                def recurse(actual: list, require: list) -> bool:
                    if len(require) == 1 and require[0] == 0:
                        return True
        Severity: Minor
        Found in contrib/seeds/asmap.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 parse_config_into_btc_config has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def parse_config_into_btc_config():
            def find_between( s, first, last ):
                try:
                    start = s.index( first ) + len( first )
                    end = s.index( last, start )
        Severity: Minor
        Found in build_msvc/msvc-autogen.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

        Severity
        Category
        Status
        Source
        Language