bitcoin/bitcoin

View on GitHub

Showing 80 of 84 total issues

Avoid too many return statements within this function.
Open

        return _BinNode(_Instruction.JUMP, node0, node1)
Severity: Major
Found in contrib/seeds/asmap.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return obj
    Severity: Major
    Found in contrib/message-capture/message-capture-parser.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return None
      Severity: Major
      Found in contrib/devtools/circular-dependencies.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return (BIP155Network.IPV6, addr_bytes)
        Severity: Major
        Found in contrib/seeds/generate-seeds.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return recurse(actual, require[0]) and recurse(actual, require[1])
          Severity: Major
          Found in contrib/seeds/asmap.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return None
            Severity: Major
            Found in contrib/seeds/makeseeds.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return (BIP155Network.CJDNS, addr_bytes)
              Severity: Major
              Found in contrib/seeds/generate-seeds.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return None
                Severity: Major
                Found in contrib/seeds/makeseeds.py - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return _BinNode(_Instruction.MATCH, 2, node0)
                  Severity: Major
                  Found in contrib/seeds/asmap.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return None
                    Severity: Major
                    Found in contrib/seeds/makeseeds.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return {
                      Severity: Major
                      Found in contrib/seeds/makeseeds.py - About 30 mins to fix

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

                        def check_ELF_RELRO(binary) -> bool:
                            '''
                            Check for read-only relocations.
                            GNU_RELRO program header must exist
                            Dynamic section must have BIND_NOW flag
                        Severity: Minor
                        Found in contrib/devtools/security-check.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 check_exported_symbols has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def check_exported_symbols(binary) -> bool:
                            ok: bool = True
                        
                            for symbol in binary.dynamic_symbols:
                                if not symbol.exported:
                        Severity: Minor
                        Found in contrib/devtools/symbol-check.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 main has a Cognitive Complexity of 6 (exceeds 5 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 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 gen_invalid_vectors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def gen_invalid_vectors():
                            '''Generate invalid test vectors'''
                            # start with some manual edge-cases
                            yield "",
                            yield "x",
                        Severity: Minor
                        Found in contrib/testgen/gen_key_io_test_vectors.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 decode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def decode(self, stream, bitpos) -> tuple[int,int]:
                                """Decode a number starting at bitpos in stream, returning value and new bitpos."""
                                val = self._minval
                                bits = 0
                                for k, bits in enumerate(self._clsbits):
                        Severity: Minor
                        Found in contrib/seeds/asmap.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 filterbyasn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: int) -> list[dict]:
                            """ Prunes `ips` by
                            (a) trimming ips to have at most `max_per_net` ips from each net (e.g. ipv4, ipv6); and
                            (b) trimming ips to have at most `max_per_asn` ips from each asn in each net.
                            """
                        Severity: Minor
                        Found in contrib/seeds/makeseeds.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 main has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def main():
                            parser = argparse.ArgumentParser(description='Bitcoin-core msbuild configuration initialiser.')
                            parser.add_argument('-toolset', nargs='?', default=DEFAULT_PLATFORM_TOOLSET,
                                help='Optionally sets the msbuild platform toolset, e.g. v143 for Visual Studio 2022.'
                                 ' default is %s.'%DEFAULT_PLATFORM_TOOLSET)
                        Severity: Minor
                        Found in build_msvc/msvc-autogen.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 insert_cmd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def insert_cmd(argv):
                            if len(argv) != 3:
                                sys.exit(INSERT_USAGE)
                        
                            filename = argv[2]
                        Severity: Minor
                        Found in contrib/devtools/copyright_header.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __init__(self, ins: _Instruction, arg1=None, arg2=None):
                                """
                                Construct a new asmap node. Possibilities are:
                                - _BinNode(_Instruction.RETURN, asn)
                                - _BinNode(_Instruction.JUMP, node_0, node_1)
                        Severity: Minor
                        Found in contrib/seeds/asmap.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

                        Severity
                        Category
                        Status
                        Source
                        Language