KAMI911/osm_poi_matchmaker

View on GitHub
osm_poi_matchmaker/dao/poi_base.py

Summary

Maintainability
D
2 days
Test Coverage

File poi_base.py has 606 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
try:
    import logging
    import sys
    import geopandas as gpd
Severity: Major
Found in osm_poi_matchmaker/dao/poi_base.py - About 1 day to fix

    Function query_osm_shop_poi_gpd has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def query_osm_shop_poi_gpd(self, lon: float, lat: float, ptype: str = 'shop', name: str = '', avoid_name: str = '', street_name: str = '',
                                   housenumber: str = '', conscriptionnumber: str = '', city: str = '',
                                   distance_perfect: int = None, distance_safe: int = None, distance_unsafe: int = None,
                                   with_metadata: bool = True):
            '''
    Severity: Minor
    Found in osm_poi_matchmaker/dao/poi_base.py - About 5 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 query_osm_shop_poi_gpd has 13 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def query_osm_shop_poi_gpd(self, lon: float, lat: float, ptype: str = 'shop', name: str = '', avoid_name: str = '', street_name: str = '',
    Severity: Major
    Found in osm_poi_matchmaker/dao/poi_base.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

              if query_name is not None and query_name != '' and city_query is not None and city_query != '' and \
                      street_query is not None and street_query != '' and \
                      housenumber_query is not None and housenumber_query != '':
                  query_text = '''
                  --- WITH NAME, WITH CITY, WITH STREETNAME, WITH HOUSENUMBER
      Severity: Critical
      Found in osm_poi_matchmaker/dao/poi_base.py - About 1 hr to fix

        Function query_osm_shop_poi_gpd has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def query_osm_shop_poi_gpd(self, lon: float, lat: float, ptype: str = 'shop', name: str = '', avoid_name: str = '', street_name: str = '',
                                       housenumber: str = '', conscriptionnumber: str = '', city: str = '',
                                       distance_perfect: int = None, distance_safe: int = None, distance_unsafe: int = None,
                                       with_metadata: bool = True):
                '''
        Severity: Minor
        Found in osm_poi_matchmaker/dao/poi_base.py - About 1 hr to fix

          Function query_osm_building_poi_gpd has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def query_osm_building_poi_gpd(self, lon, lat, city, postcode, street_name='', housenumber='',
          Severity: Major
          Found in osm_poi_matchmaker/dao/poi_base.py - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    if query_name is not None and query_name != '' and city_query is not None and city_query != '' and \
                            conscriptionnumber_query is not None and conscriptionnumber_query != '':
                        query_text = '''
                        --- WITH NAME, WITH CONSCRIPTINNUMBER, WITH CITY
                        --- The way selector with conscriptionnumber and city
            Severity: Major
            Found in osm_poi_matchmaker/dao/poi_base.py - About 40 mins to fix

              Function query_name_road_around has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def query_name_road_around(self, lon, lat, name='', with_metadata=True, mode='both'):
              Severity: Minor
              Found in osm_poi_matchmaker/dao/poi_base.py - About 35 mins to fix

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

                    def query_name_road_around(self, lon, lat, name='', with_metadata=True, mode='both'):
                        '''
                        Search for road with name specified around the lon, lat point location in OpenStreetMap database based on
                        within preconfigured distance
                        :param lon: Longitude parameter. Looking for roads around this geom.
                Severity: Minor
                Found in osm_poi_matchmaker/dao/poi_base.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

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

                    def __init__(self, db_connection, retry_counter=100, retry_sleep=30):
                        reco = 0  # Actual retry counter
                        self.db_retry_counter = retry_counter
                        self.db_retry_sleep = retry_sleep
                        self.db_connection = db_connection
                Severity: Minor
                Found in osm_poi_matchmaker/dao/poi_base.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

                There are no issues that match your filters.

                Category
                Status