agrenott/pyhgtmap

View on GitHub

Showing 56 of 56 total issues

File file.py has 657 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import annotations

import logging
import os
import sys
Severity: Major
Found in pyhgtmap/hgt/file.py - About 1 day to fix

    File NASASRTMUtil.py has 636 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from __future__ import annotations, print_function
    
    import base64
    import os
    import sys
    Severity: Major
    Found in pyhgtmap/NASASRTMUtil.py - About 1 day to fix

      Function make_tiles has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
      Open

          def make_tiles(self, opts: Configuration) -> list[HgtTile]:
              """generate tiles from self.zData according to the given <opts>.area and
              return them as list of hgtTile objects.
              """
              area = opts.area or None
      Severity: Minor
      Found in pyhgtmap/hgt/file.py - About 1 day 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 cli.py has 537 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from __future__ import annotations
      
      import os
      import sys
      from typing import cast
      Severity: Major
      Found in pyhgtmap/cli.py - About 1 day to fix

        Function calcBbox has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

        def calcBbox(area, corrx=0.0, corry=0.0):
            """calculates the appropriate bouding box for the needed files"""
            minLon, minLat, maxLon, maxLat = [
                float(value) - inc
                for value, inc in zip(area.split(":"), [corrx, corry, corrx, corry])
        Severity: Minor
        Found in pyhgtmap/NASASRTMUtil.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

        Function initDirs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def initDirs(sources: List[str]) -> None:
            mkdir(NASASRTMUtilConfig.hgtSaveDir)
            for source in sources:
                source_type, source_resolution = source[:4], int(source[4])
                if source_type == "srtm":
        Severity: Minor
        Found in pyhgtmap/NASASRTMUtil.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

        Function getNASAUrl has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def getNASAUrl(area, resolution, srtmVersion):
            """determines the NASA download url for a given area."""
            hgtIndexFile = NASASRTMUtilConfig.NASAhgtIndexFileRe.format(resolution, srtmVersion)
            hgtFileServer = NASASRTMUtilConfig.getSRTMFileServer(resolution, srtmVersion)
            try:
        Severity: Minor
        Found in pyhgtmap/NASASRTMUtil.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

        Function makeNasaHgtIndex has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        def makeNasaHgtIndex(resolution, srtmVersion):
            """generates an index file for the NASA SRTM server."""
            hgtIndexFile = NASASRTMUtilConfig.NASAhgtIndexFileRe.format(resolution, srtmVersion)
            if srtmVersion == 2.1:
                hgtIndexFileOldName = hgtIndexFile[:-9] + hgtIndexFile[-4:]
        Severity: Minor
        Found in pyhgtmap/NASASRTMUtil.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

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

        def intersecTiles(polygonList, corrx, corry):
            if not polygonList:
                return []
            secs = []
            for polygon in polygonList:
        Severity: Minor
        Found in pyhgtmap/NASASRTMUtil.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

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

        def makeFileNamePrefixes(bbox, polygon, corrx, corry, lowercase=False):
            """generates a list of filename prefixes of the files containing data within the
            bounding box.
            """
            minLon, minLat, maxLon, maxLat = bbox
        Severity: Minor
        Found in pyhgtmap/NASASRTMUtil.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 getSRTMv3Areas has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def getSRTMv3Areas(polygons):
            rawAreas = []
            for p in polygons:
                lons = sorted([el[0] for el in p])
                lats = sorted([el[1] for el in p])
        Severity: Minor
        Found in pyhgtmap/NASASRTMUtil.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 load has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def load(self) -> None:
                """Load index from local file"""
                with open(self._index_file_name) as index_file:
                    current_url = None
                    for line in index_file:
        Severity: Minor
        Found in pyhgtmap/sources/viewfinder.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 make_osm_filename has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def make_osm_filename(
            borders: BBox,
            opts: Configuration,
            input_files_names: list[str],
        ) -> str:
        Severity: Minor
        Found in pyhgtmap/output/factory.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 build_common_parser has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def build_common_parser() -> ArgumentParser:
            parser = ArgumentParser(
                default_config_files=[CONFIG_FILENAME],
                usage="%(prog)s [options] [<hgt or GeoTiff file>] [<hgt or GeoTiff files>]"
                "\npyhgtmap generates contour lines from NASA SRTM and similar data"
        Severity: Minor
        Found in pyhgtmap/cli.py - About 1 hr to fix

          Function parse_polygons_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def parse_polygons_file(filename: str) -> tuple[str, PolygonsList]:
              """reads polygons from a file like one included in
              http://download.geofabrik.de/clipbounds/clipbounds.tgz
              and returns it as list of (<lon>, <lat>) tuples.
              """
          Severity: Minor
          Found in pyhgtmap/hgt/file.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 areaNeeded has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def areaNeeded(lat, lon, bbox, polygon, corrx, corry):
              """checks if a source file is needed depending on the bounding box and
              the passed polygon.
              """
              if polygon is None:
          Severity: Minor
          Found in pyhgtmap/NASASRTMUtil.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(
          Severity: Major
          Found in pyhgtmap/hgt/file.py - About 1 hr to fix

            Function main_internal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def main_internal(sys_args: list[str]) -> None:
                opts, args = parse_command_line(sys_args)
                configure_logging(opts.logLevel)
            
                hgtDataFiles: list[tuple[str, bool]]
            Severity: Minor
            Found in pyhgtmap/main.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 downloadAndUnzip_Zip has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def downloadAndUnzip_Zip(opener, url, area, source):
                hgtSaveDir, hgtSaveSubDir = getDirNames(source)
                fileResolution = int(source[4])
                saveZipFilename = os.path.join(hgtSaveSubDir, url.split("/")[-1])
                saveFilename = os.path.join(hgtSaveSubDir, "{0:s}.hgt".format(area))
            Severity: Minor
            Found in pyhgtmap/NASASRTMUtil.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 getFiles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def getFiles(
                area: str,
                polygon: PolygonsList | None,
                corrx: float,
                corry: float,
            Severity: Minor
            Found in pyhgtmap/NASASRTMUtil.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

            Severity
            Category
            Status
            Source
            Language