codeforamerica/intake

View on GitHub

Showing 66 of 168 total issues

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

    def handle(self, *args, **options):
        dup_sets = SubmissionsService.find_duplicates(
            models.FormSubmission.objects.all())
        self.stdout.write("Found {} duplicate sets".format(len(dup_sets)))
        existing_dup_sets = models.DuplicateSubmissionSet.objects.all()
Severity: Minor
Found in intake/management/commands/find_all_duplicates.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 makeOrgChart has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function makeOrgChart (parent, chartConfig, orgData) {
    var dataArray = config.getDataForChart(chartConfig, orgData);
    if (dataArray === null) {
        // don't buld the chart if there is no data available.
        console.log(orgData.org.name, "no data for", chartConfig.chartName, "!!!");
Severity: Minor
Found in intake/static/intake/js/org_charts.js - About 1 hr to fix

    Function buildSearchFunction has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function buildSearchFunction(searchSpace){
      return function (searchTerm){
        searchTerm = searchTerm.trim();
        var termLength = searchTerm.length;
        var results = [];
    Severity: Minor
    Found in intake/static/intake/js/tag_search.js - About 1 hr to fix

      Function initializeSearchWidget has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function initializeSearchWidget(inputSelector, postURL, resultsCallback, emptySearchCallback){
        var currentXHR = null;
      
        function handleResultsAndResetRequest(callback){
          return function(results){
      Severity: Minor
      Found in intake/static/intake/js/search_widget.js - About 1 hr to fix

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

            def handle(self, *args, **options):
                subs = models.FormSubmission.objects.filter(dob__isnull=True)
                migrated = 0
                errored = 0
                for sub in subs:
        Severity: Minor
        Found in intake/management/commands/migrate_dob.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_django_validation_error has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_django_validation_error(self, error):
                """Django's ValidationError can include lists of errors,
                dicts of errors or just have a simple error message.
                This method is responsible for pulling error messages out of
                Django ValidationError objects and selecting the right way to
        Severity: Minor
        Found in formation/base.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 _fill has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _fill(self, pdf_path, output_path, option_check, answers):
                answer_fields = {'fields': []}
                # TODO: make this less nested
                for k, v in answers.items():
                    if k in option_check:
        Severity: Minor
        Found in intake/pdfparser.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 count_unreads_and_send_notifications_to_orgs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def count_unreads_and_send_notifications_to_orgs():
            orgs = get_orgs_that_might_need_a_bundle_email_today()
            errors = []
            for org in orgs:
                if org.slug != 'cfa':
        Severity: Minor
        Found in intake/services/bundles.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 followUpQuestion has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var followUpQuestion = (function() {
          var fUQ = {
            init: function() {
        
              // if any initial questions are already selected on page load, show the follow up
        Severity: Minor
        Found in intake/static/intake/js/application.js - About 1 hr to fix

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

              def __init__(self, *args, form=None, required=True, recommended=False,
          Severity: Major
          Found in formation/field_base.py - About 1 hr to fix

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

            def link_with_any_duplicates(submission, applicant_id):
                """Links submission with any duplicates from the same applicant
            
                If duplicates are found, returns the DuplicateSubmissionSet id
                If no duplicates are found, returns False
            Severity: Minor
            Found in intake/services/submissions.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 dont_audit_fixture_loading has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def dont_audit_fixture_loading(
            Severity: Major
            Found in access_audit/helpers.py - About 50 mins to fix

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

                  def log_multiple(cls, event_type, submission_ids,
              Severity: Major
              Found in intake/models/application_log_entry.py - About 50 mins to fix

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

                def concatenated_printout(form_letter_tuples):
                    canvas = None
                    pdf_file = None
                    count = len(form_letter_tuples)
                    for i, form_letter_tuple in enumerate(form_letter_tuples):
                Severity: Minor
                Found in intake/services/pdf_service.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 drawStreamFractionsChart has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function drawStreamFractionsChart (chart, chartConfig, sizes, data, xScale, yScale) {
                Severity: Minor
                Found in intake/static/intake/js/org_charts.js - About 45 mins to fix

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

                      def get_existing_model(cls, data, lookup, qset):
                          for instance in qset:
                              is_object = True
                              for key in lookup:
                                  if getattr(instance, key, None) != lookup[key]:
                  Severity: Minor
                  Found in project/migration_utils.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 drawLineChart has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function drawLineChart (chart, chartConfig, sizes, data, xScale, yScale) {
                  Severity: Minor
                  Found in intake/static/intake/js/org_charts.js - About 45 mins to fix

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

                    def build_bundled_pdf_if_necessary(bundle):
                        """Populates `bundled_pdf` attribute if needed
                    
                        First checks whether or not there should be a pdf. If so,
                        - tries to grab filled pdfs for the bundles submissions
                    Severity: Minor
                    Found in intake/services/bundles.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 to_representation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def to_representation(self, obj):
                            mini_form = ContactInfoMiniForm(obj)
                            contact_preferences = obj.get('contact_preferences', [])
                            output = []
                            for key in ('sms', 'email', 'voicemail', 'snailmail'):
                    Severity: Minor
                    Found in intake/serializers/fields.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 checkboxSelector has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    var checkboxSelector = (function() {
                      var cs = {
                        init: function() {
                          $('.checkbox').each(function(index, button){
                            if($(this).find('input').is(':checked')) {
                    Severity: Minor
                    Found in intake/static/intake/js/application.js - 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

                    Severity
                    Category
                    Status
                    Source
                    Language