failmap/admin

View on GitHub

Showing 577 of 577 total issues

Function handle has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def handle(self, *app_labels, **options):
        merge_date = datetime(year=2019, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.utc)

        """
        De gemeenten Dongeradeel, Ferwerderadiel en Kollumerland en Nieuwkruisland: samenvoeging tot een

    Function test_internet_nl_logging has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def test_internet_nl_logging(db):
    
        # todo: make sure that never an empty list is added in normal situations?
        scan = initialize_scan("web", [])
        last = InternetNLV2StateLog.objects.all().last()
    Severity: Minor
    Found in websecmap/scanners/tests/test_internet_nl_v2.py - About 1 hr to fix

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

      def store_when_new_or_kill_if_gone(connected, url, port, protocol, ip_version):
          """
      
          :param url: any url where endpoints are discovered.
          :param port: any port: 1 to 65535
      Severity: Minor
      Found in websecmap/scanners/scanner/ftp.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_submitted_urls has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_submitted_urls(contest):
          # Don't use to_attr or prefetch related, as it is not maintainable code and i could not get it to work at all for
          # hours. which was such a waste.
      
          submitted_urls = (
      Severity: Minor
      Found in websecmap/game/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 is_improved has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def is_improved(first_scan, last_scan):
          if first_scan == "high":
              return True if last_scan in ["medium", "low", "good"] else False
          if first_scan == "medium":
              return True if last_scan in ["low", "good"] else False
      Severity: Minor
      Found in websecmap/scanners/impact.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 save_model has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def save_model(self, request, obj, form, change):
              # allows to place a new item at the right position, moving certain items up.
              # if the display_order is zero, autoplace the item.
      
              if obj.display_order:
      Severity: Minor
      Found in websecmap/map/admin.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 organization_and_url_import has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def organization_and_url_import(flat_organizations: List[Dict[str, Any]]):
      
          if not config.GOOGLE_MAPS_API_KEY:
              log.warning("Warning: the google maps api key is not set, fallback geocoding of addresses will not happen.")
      
      
      Severity: Minor
      Found in websecmap/api/apis/zorgkaart.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 item_title has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def item_title(self, item):
              rating = (
                  _("Perfect")
                  if not any([item["high"], item["medium"], item["low"]])
                  else _("High")
      Severity: Minor
      Found in websecmap/map/logic/rss_feeds.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 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self, *args, **options):
      
              organization_types = dict(OrganizationType.objects.all().values_list("pk", "name", flat=False))
              matches = []
      
      

      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 add_statistics_to_calculation has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def add_statistics_to_calculation(calculation, amount_of_issues):
          # inject all kinds of statistics inside the json for easier(?) representation.
          calculation["total_issues"] = amount_of_issues["overall"]["any"]
          calculation["high"] = amount_of_issues["overall"]["high"]
          calculation["medium"] = amount_of_issues["overall"]["medium"]
      Severity: Minor
      Found in websecmap/reporting/report.py - About 1 hr to fix

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        VENDOR_DIR = os.environ.get("VENDOR_DIR", os.path.abspath(os.path.dirname(__file__) + "/../vendor/") + "/")
        Severity: Major
        Found in websecmap/settings.py and 2 other locations - About 1 hr to fix
        websecmap/settings.py on lines 380..380
        websecmap/settings.py on lines 384..384

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @transaction.atomic
            def disallow_team(self, request, queryset):
                for team in queryset:
                    team.allowed_to_submit_things = False
                    team.save()
        Severity: Major
        Found in websecmap/game/admin.py and 3 other locations - About 1 hr to fix
        websecmap/game/admin.py on lines 629..635
        websecmap/game/admin.py on lines 727..733
        websecmap/game/admin.py on lines 866..872

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        VENDOR_DIR = os.environ.get("VENDOR_DIR", os.path.abspath(os.path.dirname(__file__) + "/../vendor/") + "/")
        Severity: Major
        Found in websecmap/settings.py and 2 other locations - About 1 hr to fix
        websecmap/settings.py on lines 384..384
        websecmap/settings.py on lines 1309..1309

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @transaction.atomic
            def reject(self, request, queryset):
                for organizationsubmission in queryset:
                    organizationsubmission.has_been_rejected = True
                    organizationsubmission.save()
        Severity: Major
        Found in websecmap/game/admin.py and 3 other locations - About 1 hr to fix
        websecmap/game/admin.py on lines 629..635
        websecmap/game/admin.py on lines 640..646
        websecmap/game/admin.py on lines 727..733

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @transaction.atomic
            def reject(self, request, queryset):
                for urlsubmission in queryset:
                    urlsubmission.has_been_rejected = True
                    urlsubmission.save()
        Severity: Major
        Found in websecmap/game/admin.py and 3 other locations - About 1 hr to fix
        websecmap/game/admin.py on lines 629..635
        websecmap/game/admin.py on lines 640..646
        websecmap/game/admin.py on lines 866..872

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

            @transaction.atomic
            def allow_team(self, request, queryset):
                for team in queryset:
                    team.allowed_to_submit_things = True
                    team.save()
        Severity: Major
        Found in websecmap/game/admin.py and 3 other locations - About 1 hr to fix
        websecmap/game/admin.py on lines 640..646
        websecmap/game/admin.py on lines 727..733
        websecmap/game/admin.py on lines 866..872

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        TOOLS_DIR = os.environ.get("TOOLS_DIR", os.path.abspath(os.path.dirname(__file__) + "/../tools/") + "/")
        Severity: Major
        Found in websecmap/settings.py and 2 other locations - About 1 hr to fix
        websecmap/settings.py on lines 380..380
        websecmap/settings.py on lines 1309..1309

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 42.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function test_autoexplain_including_headers has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def test_autoexplain_including_headers(db, monkeypatch):
            url, created = Url.objects.all().get_or_create(url="lyncdiscover.arnhem.nl")
            endpoint, created = Endpoint.objects.all().get_or_create(url=url, protocol="https", port="443", ip_version=4)
            endpointscan, created = EndpointGenericScan.objects.all().get_or_create(
                endpoint=endpoint,
        Severity: Minor
        Found in websecmap/scanners/tests/test_autoexplain.py - About 1 hr to fix

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

              def save_model(self, request, obj, form, change):
          
                  # log.info(form.changed_data)
                  # grrr, both area and edit_area are ALWAYS changed... even if you didn't change the values in these
                  # fields... this is obviously a bug or "optimization". We now have to resort to queries to figure out
          Severity: Minor
          Found in websecmap/organizations/admin.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 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle(self, *args, **options):
                  """Optionally run migrations and load data."""
          
                  try:
                      subprocess.check_call("command -v uwsgi", shell=True, stdout=subprocess.DEVNULL)
          Severity: Minor
          Found in websecmap/app/management/commands/production.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