elnappo/project-novis

View on GitHub

Showing 21 of 102 total issues

File models.py has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from decimal import Decimal

from django.contrib.auth import get_user_model
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point
Severity: Minor
Found in project_novis/callsign/models.py - About 4 hrs to fix

    Function handle has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
    
            self.stdout.write("Import repeater from repeatermap.de")
            r = requests.get(options['url'], stream=False)
            if r.ok:
    Severity: Minor
    Found in project_novis/callsign/management/commands/import_repeatermap.py - About 4 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 handle has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            r = requests.get(options['url'], stream=False)
            if r.ok:
                repeaters = r.json()
                for repeater in repeaters:
    Severity: Minor
    Found in project_novis/callsign/management/commands/import_dmr_repeater.py - About 3 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 handle has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            r = requests.get(options['url'], stream=False)
    
            if r.ok:
                data = BytesIO(r.content)
    Severity: Minor
    Found in project_novis/callsign/management/commands/import_clublog.py - About 3 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 finland has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def finland(self):
            # Based on https://github.com/OH6AD/koolit
            url: str = "https://eservices.viestintavirasto.fi/Licensesservices/Forms/AmateurLicenses.aspx"
            payload: dict = {'__EVENTTARGET': '', 'ButtonDownload': ''}
            callsigns = list()
    Severity: Minor
    Found in project_novis/callsign/management/commands/import_official.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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, url):
            r = self.session.get(url, stream=False)
    
            if r.status_code != 200:
                raise Exception(f"Failed to download {url} status code {r.status_code}")
    Severity: Minor
    Found in project_novis/callsign/management/commands/import_lotw.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 grid_to_point has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def grid_to_point(grid: str) -> Point:
        """
        Converts Maidenhead locator in the corresponding WGS84 coordinates
        Based on https://github.com/dh1tw/pyhamtools/blob/master/pyhamtools/locator.py
        """
    Severity: Minor
    Found in project_novis/callsign/utils.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 germany has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def germany(self):
            # update v parameter?
            url: str = "https://www.bundesnetzagentur.de/SharedDocs/Downloads/DE/Sachgebiete/Telekommunikation/Unternehmen_Institutionen/Frequenzen/Amateurfunk/Rufzeichenliste/Rufzeichenliste_AFU.pdf?__blob=publicationFile&v=51"
            regex = re.compile(r"D[A-Z][0-9][A-Z0-9]+")
            callsigns = list()
    Severity: Minor
    Found in project_novis/callsign/management/commands/import_official.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 address_to_point has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def address_to_point(address: str, provider: str = "arcgis", session=None, use_cache: bool = True) -> Point:
        # use provider string as function name
        _geocoder = getattr(geocoder, provider)
        AddressLocationCache = apps.get_model('callsign', 'AddressLocationCache')
    
    
    Severity: Minor
    Found in project_novis/callsign/utils.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 _handle_callsign has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def _handle_callsign(self, callsign: str, source: str = "", official: bool = False, return_instance: bool = True) -> Tuple[Callsign, bool]:
            self._callsign_counter += 1
            raw_callsign = extract_callsign(callsign)
    
            if not raw_callsign:
    Severity: Minor
    Found in project_novis/callsign/management/commands/__init__.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 _filter_callsigns_bulk_create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _filter_callsigns_bulk_create(self, callsigns: Iterable[str], extra_fields=None, source: str = "", official: bool = False) -> Iterator[Callsign]:
            """Create a list of Callsign instances from dirty callsigns.
    
            Filter out already existing, blacklisted and invalid callsigns.
    
    
    Severity: Minor
    Found in project_novis/callsign/management/commands/__init__.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 dispatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def dispatch(self, request, *args, **kwargs):
            # Create an Repeater instance if does not exist
            try:
                self.get_object()
            except Http404:
    Severity: Minor
    Found in project_novis/callsign/views.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 dispatch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def dispatch(self, request, *args, **kwargs):
            # Create an Club instance if does not exist
            try:
                self.get_object()
            except Http404:
    Severity: Minor
    Found in project_novis/callsign/views.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 amateurradio_digital has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def amateurradio_digital(self, options):
            self._write("Import amateurradio.digital data")
    
            r = self.session.get(options['url'], stream=False)
    
    
    Severity: Minor
    Found in project_novis/callsign/management/commands/import_digital.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 _callsign_bulk_create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _callsign_bulk_create(self, callsigns: Iterable[str], extra_fields=None, source: str = "", official: bool = False) -> List[Callsign]:
            """Create callsigns and set default meta data
    
            Takes a list of dirty callsigns and adds the ones missing from database. Also set the default meta data, e.g.
            prefix, location,...
    Severity: Minor
    Found in project_novis/callsign/management/commands/__init__.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

    Avoid deeply nested control flow statements.
    Open

                            for attr, a_value in clublog_user_data.items():
                                setattr(clublog_instance, attr, a_value)
                            clublog_instance.save()
    Severity: Major
    Found in project_novis/callsign/management/commands/import_clublog.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if not callsign_instance._official_validated:
                                  callsign_instance._official_validated = True
                                  callsign_instance.save()
      
      
      Severity: Major
      Found in project_novis/callsign/management/commands/import_official.py - About 45 mins to fix

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

        def address_to_grid_based_point(address: str,
        Severity: Minor
        Found in project_novis/callsign/utils.py - About 35 mins to fix

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

              def validate(self, attrs):
                  username = attrs.get('username')
                  password = attrs.get('password')
          
                  if username and password:
          Severity: Minor
          Found in project_novis/radius/serializers.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 extract_callsign has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def extract_callsign(value: str) -> str:
              value: str = value.replace(" ", "").upper()
              callsign: str = ""
          
              if CALLSIGN_REGEX_COMPILE.search(value):
          Severity: Minor
          Found in project_novis/callsign/utils.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