project-callisto/callisto-core

View on GitHub

Showing 19 of 28 total issues

File report_delivery.py has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import logging
import os
from collections import OrderedDict
from io import BytesIO
Severity: Minor
Found in callisto_core/reporting/report_delivery.py - About 5 hrs to fix

    File api.py has 361 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import copy
    import logging
    import os
    import typing
    
    
    Severity: Minor
    Found in callisto_core/notification/api.py - About 4 hrs to fix

      CallistoCoreNotificationApi has 34 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CallistoCoreNotificationApi(object):
      
          report_filename = "callisto_record_{0}.pdf.gpg"
          report_title = "Callisto Record"
          logo_path = "../../assets/callisto_logo.png"
      Severity: Minor
      Found in callisto_core/notification/api.py - About 4 hrs to fix

        File view_partials.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        
        View partials provide all the callisto-core front-end functionality.
        Subclass these partials with your own views if you are implementing
        callisto-core. Many of the view partials only provide a subset of the
        Severity: Minor
        Found in callisto_core/reporting/view_partials.py - About 2 hrs to fix

          StepsHelper has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class StepsHelper(object):
              done_name = "done"
              review_name = "Review"
              next_name = "Next"
              back_name = "Back"
          Severity: Minor
          Found in callisto_core/wizard_builder/view_helpers.py - About 2 hrs to fix

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

                def clean(self):
                    identifiers = set()
                    identifier_type = ""
                    identifier_types = validators.perp_identifiers()
                    from django.core.exceptions import ValidationError
            Severity: Minor
            Found in callisto_core/reporting/forms.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 set_up_styles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def set_up_styles(self, *args, **kwargs):
                    """
                    Helper formatting methods assume the following styles have been defined:
                        * Normal: format_question, get_metadata_page
                        * Notes: get_metadata_page
            Severity: Minor
            Found in callisto_core/reporting/report_delivery.py - About 1 hr to fix

              Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(
              Severity: Major
              Found in callisto_core/reporting/report_delivery.py - About 50 mins to fix

                Function facebook_validation_function has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def facebook_validation_function(url):
                    try:
                        url_parts = _get_url_parts(url)
                        # check if acceptable domain
                        domain = url_parts[1]
                Severity: Minor
                Found in callisto_core/reporting/validators.py - About 45 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 send_report_to_authority has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def send_report_to_authority(
                Severity: Minor
                Found in callisto_core/notification/api.py - About 45 mins to fix

                  Function slack_notification has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def slack_notification(
                  Severity: Minor
                  Found in callisto_core/notification/api.py - About 45 mins to fix

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

                        def dispatch(self, request, token=None, uidb64=None, *args, **kwargs):
                    Severity: Minor
                    Found in callisto_core/reporting/view_partials.py - About 35 mins to fix

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

                          def send_user_review_nofication(
                      Severity: Minor
                      Found in callisto_core/notification/api.py - About 35 mins to fix

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

                            def on_retry(self, exc, task_id, args, kwargs, einfo):
                        Severity: Minor
                        Found in callisto_core/celeryconfig/tasks.py - About 35 mins to fix

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

                              def on_failure(self, exc, task_id, args, kwargs, einfo):
                          Severity: Minor
                          Found in callisto_core/celeryconfig/tasks.py - About 35 mins to fix

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

                            def twitter_validation_function(value):
                                path = None
                                try:
                                    url_parts = _get_url_parts(value)
                                    # check if acceptable domain
                            Severity: Minor
                            Found in callisto_core/reporting/validators.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 authenticate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def authenticate(self, request, username, password):
                                    username = sha256(username.encode("utf-8")).hexdigest()
                                    username_index = index(username)
                                    for user in Account.objects.filter(username_index=username_index):
                                        if not user or not bcrypt.checkpw(
                            Severity: Minor
                            Found in callisto_core/accounts/auth.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 _passphrase_next_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _passphrase_next_url(self, request):
                                    next_url = None
                                    if "next" in request.GET:
                                        if re.search(r"^/[\W/-]*", request.GET["next"]):
                                            if is_safe_url(request.GET["next"]):
                            Severity: Minor
                            Found in callisto_core/delivery/view_partials.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 dispatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def dispatch(self, request, *args, **kwargs):
                                    logger.debug(f"{self.__class__.__name__} access check")
                            
                                    if (
                                        self.access_granted or self.access_form_valid
                            Severity: Minor
                            Found in callisto_core/delivery/view_partials.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