Showing 349 of 349 total issues

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

    filter_multi_fields = [
        ('election_state', models.ElectionDate.election_state),
        ('election_district', models.ElectionDate.election_district),
        ('election_party', models.ElectionDate.election_party),
        ('office_sought', models.ElectionDate.office_sought),
Severity: Major
Found in webservices/resources/dates.py and 3 other locations - About 2 hrs to fix
webservices/resources/committees.py on lines 41..47
webservices/resources/sched_a.py on lines 33..39
webservices/resources/sched_b.py on lines 30..36

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 54.

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

File reports.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import sqlalchemy as sa
from flask_apispec import doc, marshal_with

from webservices import args
from webservices import docs
Severity: Minor
Found in webservices/resources/reports.py - About 2 hrs to fix

    Function parse_option has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_option(option, model=None, aliases=None, join_columns=None, query=None):
        """Parse sort option to SQLAlchemy order expression.
    
        :param str option: Column name, possibly prefixed with "-"
        :param model: Optional SQLAlchemy model to sort on
    Severity: Minor
    Found in webservices/sorting.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

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

          if (jQuery.trim($(this).val()) === '') {
            $(this).addClass('error');
            $(this).wiggle({
              callback: (function(_this) {
                return function() {
    Severity: Major
    Found in swagger-ui/js/view/OperationView.js and 1 other location - About 2 hrs to fix
    swagger-ui/js/view/OperationView.js on lines 280..290

    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 79.

    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 2 locations. Consider refactoring.
    Open

          if (this.selectedIndex === -1) {
            $(this).addClass('error');
            $(this).wiggle({
              callback: (function(_this) {
                return function() {
    Severity: Major
    Found in swagger-ui/js/view/OperationView.js and 1 other location - About 2 hrs to fix
    swagger-ui/js/view/OperationView.js on lines 252..262

    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 79.

    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

    File legal.py has 255 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import re
    
    from elasticsearch_dsl import Search, Q
    from webargs import fields
    from flask import abort
    Severity: Minor
    Found in webservices/resources/legal.py - About 2 hrs to fix

      Function execute_query has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def execute_query(query):
          es_results = query.execute()
          formatted_hits = []
          for hit in es_results:
              formatted_hit = hit.to_dict()
      Severity: Minor
      Found in webservices/resources/legal.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 render has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render: function() {
          var type = this.model.type || this.model.dataType;
      
          if (typeof type === 'undefined') {
            var schema = this.model.schema;
      Severity: Major
      Found in swagger-ui/js/view/ParameterView.js - About 2 hrs to fix

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

            @locust.task
            def load_schedule_a_problematic(self):
                params = random.choice(poor_performance_a)
                params['api_key'] = API_KEY
                self.client.get('schedules/schedule_a/', name='load_schedule_a_problematic', params=params)
        Severity: Major
        Found in locustfile.py and 4 other locations - About 2 hrs to fix
        locustfile.py on lines 203..207
        locustfile.py on lines 209..213
        locustfile.py on lines 215..219
        locustfile.py on lines 227..231

        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 50.

        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

            filter_range_fields = [
                (('min_date', 'max_date'), models.ScheduleC.incurred_date),
                (('min_amount', 'max_amount'), models.ScheduleC.original_loan_amount),
                (('min_image_number', 'max_image_number'), models.ScheduleC.image_number),
                (('min_payment_to_date', 'max_payment_to_date'), models.ScheduleC.payment_to_date),
        Severity: Major
        Found in webservices/resources/sched_c.py and 2 other locations - About 2 hrs to fix
        webservices/resources/dates.py on lines 77..81
        webservices/resources/sched_d.py on lines 31..35

        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 50.

        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 5 locations. Consider refactoring.
        Open

            @locust.task
            def load_schedule_b_problematic(self):
                params = random.choice(poor_performance_b)
                params['api_key'] = API_KEY
                self.client.get('schedules/schedule_b/', name='load_schedule_b_problematic', params=params)
        Severity: Major
        Found in locustfile.py and 4 other locations - About 2 hrs to fix
        locustfile.py on lines 203..207
        locustfile.py on lines 209..213
        locustfile.py on lines 215..219
        locustfile.py on lines 221..225

        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 50.

        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 5 locations. Consider refactoring.
        Open

            @locust.task
            def load_schedule_a_large(self):
                params = random.choice(large_records_sched_a)
                params['api_key'] = API_KEY
                self.client.get('schedules/schedule_a/', name='load_schedule_a_large', params=params)
        Severity: Major
        Found in locustfile.py and 4 other locations - About 2 hrs to fix
        locustfile.py on lines 203..207
        locustfile.py on lines 209..213
        locustfile.py on lines 221..225
        locustfile.py on lines 227..231

        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 50.

        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

            filter_range_fields = [
                (('min_election_date', 'max_election_date'), models.ElectionDate.election_date),
                (('min_update_date', 'max_update_date'), models.ElectionDate.update_date),
                (('min_create_date', 'max_create_date'), models.ElectionDate.create_date),
                (('min_primary_general_date', 'max_primary_general_date'), models.ElectionDate.primary_general_date),
        Severity: Major
        Found in webservices/resources/dates.py and 2 other locations - About 2 hrs to fix
        webservices/resources/sched_c.py on lines 37..41
        webservices/resources/sched_d.py on lines 31..35

        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 50.

        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 5 locations. Consider refactoring.
        Open

            @locust.task
            def load_schedule_a_small(self):
                params = random.choice(small_records_sched_a)
                params['api_key'] = API_KEY
                self.client.get('schedules/schedule_a/', name='schedule_a_small', params=params)
        Severity: Major
        Found in locustfile.py and 4 other locations - About 2 hrs to fix
        locustfile.py on lines 209..213
        locustfile.py on lines 215..219
        locustfile.py on lines 221..225
        locustfile.py on lines 227..231

        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 50.

        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 5 locations. Consider refactoring.
        Open

            @locust.task
            def load_schedule_a_medium(self):
                params = random.choice(medium_records_sched_a)
                params['api_key'] = API_KEY
                self.client.get('schedules/schedule_a/', name='schedule_a_medium', params=params)
        Severity: Major
        Found in locustfile.py and 4 other locations - About 2 hrs to fix
        locustfile.py on lines 203..207
        locustfile.py on lines 215..219
        locustfile.py on lines 221..225
        locustfile.py on lines 227..231

        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 50.

        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

            filter_range_fields = [
                (('min_date', 'max_date'), models.ScheduleD.load_date),
                (('min_payment_period', 'max_payment_period'), models.ScheduleD.payment_period),
                (('min_amount_incurred_period', 'max_amount_incurred_period'), models.ScheduleD.amount_incurred_period),
                (('min_image_number', 'max_image_number'), models.ScheduleD.image_number),
        Severity: Major
        Found in webservices/resources/sched_d.py and 2 other locations - About 2 hrs to fix
        webservices/resources/dates.py on lines 77..81
        webservices/resources/sched_c.py on lines 37..41

        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 50.

        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 2 locations. Consider refactoring.
        Open

            @property
            def args(self):
                return utils.extend(
                    args.itemized,
                    args.schedule_e,
        Severity: Major
        Found in webservices/resources/sched_e.py and 1 other location - About 1 hr to fix
        webservices/resources/sched_a.py on lines 60..71

        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 49.

        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 2 locations. Consider refactoring.
        Open

            @property
            def args(self):
                return utils.extend(
                    args.itemized,
                    args.schedule_a,
        Severity: Major
        Found in webservices/resources/sched_a.py and 1 other location - About 1 hr to fix
        webservices/resources/sched_e.py on lines 63..74

        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 49.

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

          initialize: function(opts){
            var sorterOption, sorterFn, key, value;
            opts = opts || {};
        
            this.router = opts.router;
        Severity: Minor
        Found in swagger-ui/js/view/MainView.js - About 1 hr to fix

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

              def filter_multi_fields(self, history, total):
                  return [
                      ('candidate_id', history.candidate_id),
                      ('election_year', total.election_year),
                      ('cycle', total.cycle),
          Severity: Major
          Found in webservices/resources/candidate_aggregates.py and 1 other location - About 1 hr to fix
          webservices/resources/candidates.py on lines 13..21

          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 47.

          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

          Severity
          Category
          Status
          Source
          Language