eregs/regulations-site

View on GitHub

Showing 86 of 405 total issues

Function toExport has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function toExport(grunt) {
  grunt.initConfig({

    /**
     * Pull in the package.json file so we can read its metadata.
Severity: Major
Found in regulations/static/config/Gruntfile.js - About 4 hrs to fix

    File preamble.py has 288 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    from __future__ import unicode_literals
    
    from collections import namedtuple
    Severity: Minor
    Found in regulations/views/preamble.py - About 2 hrs to fix

      Function sendEvent has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        sendEvent: function sendEvent(context) {
          const objectParts = [];
          let object = '';
      
          if (typeof window.ga === 'undefined') {

      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_child has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      def add_child(parent_node, node):
          "Add a child node to a parent, maintaining the order of the children."
      
          children = parent_node['children']
          children.append(node)
      Severity: Minor
      Found in regulations/generator/layers/tree_builder.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

      File main-view.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import storage from '../../redux/storage';
      import { locationActiveEvt } from '../../redux/locationReduce';
      import { paneActiveEvt } from '../../redux/paneReduce';
      
      const $ = require('jquery');
      Severity: Minor
      Found in regulations/static/regulations/js/source/views/main/main-view.js - About 2 hrs to fix

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

        def fetch_toc(reg_part, version, flatten=False):
            """Fetch the toc, transform it into a list usable by navigation, etc."""
            toc = api_reader.ApiReader().layer('toc', 'cfr', reg_part, version)
            if toc is None:
                logger.warning("404 when fetching TOC for %s@%s", reg_part, version)
        Severity: Minor
        Found in regulations/generator/toc.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 __init__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, eregs_url, regulations=None):
                """ kick off calling regulations website for caching purposes
        
                    Keyword arguments:
                    eregs_url -- full web url to main regulations page
        Severity: Minor
        Found in regulations/management/commands/eregs_cache.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 get_context_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_context_data(self, doc_type, **kwargs):
                # We don't want to run the content data of PartialView -- it assumes
                # we will be applying layers
                context = super(PartialView, self).get_context_data(**kwargs)
        
        
        Severity: Minor
        Found in regulations/views/partial_search.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 indexOf has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          Array.prototype.indexOf = function indexOf(searchElement, initialIndex) {
            let fromIndex = initialIndex;
            if (this === undefined || this === null) {
              throw new TypeError('"this" is null or not defined');
            }
        Severity: Minor
        Found in regulations/static/regulations/js/source/helpers.js - 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 interp has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def interp(self, citation, version):
                """Subterps throw a big monkey-wrench into things. Citations to
                interpretations must be converted into their corresponding subterp,
                which requires loading the toc."""
                reg_part = citation[0]
        Severity: Minor
        Found in regulations/generator/section_url.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 make_label_sortable has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def make_label_sortable(label, roman=False):
            """ Make labels sortable, but converting them as appropriate.
            Also, appendices have labels that look like 30(a), we make those
            appropriately sortable. """
        
        
        Severity: Minor
        Found in regulations/generator/layers/tree_builder.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 notice_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        def notice_data(doc_number):
            preamble = ApiReader().preamble(doc_number.replace('-', '_'))
            if preamble is None:
                raise Http404
        
        
        Severity: Minor
        Found in regulations/views/preamble.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 sendEvent has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          sendEvent: function sendEvent(context) {
            const objectParts = [];
            let object = '';
        
            if (typeof window.ga === 'undefined') {

          Function test_toc_interp has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def test_toc_interp(self):
                  so_far = [
                      {'index': ['1001', '1']},
                      {'index': ['1001', '2']},
                      {'index': ['1001', 'A'], 'is_appendix': True},
          Severity: Minor
          Found in regulations/tests/generator_toc_tests.py - About 1 hr to fix

            Function test_definition has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def test_definition(self):
                    self.driver.set_window_size(1024, 600)
                    self.driver.get(self.test_url + '/1005-1/2012-12121')
                    html = self.driver.find_element_by_tag_name('html')
                    WebDriverWait(self.driver, 30).until(
            Severity: Minor
            Found in regulations/uitests/definition_test.py - About 1 hr to fix

              Function attach_metadata has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                  def attach_metadata(self, node):
                      text_index = node['label_id']
                      if text_index in self.layer:
                          layer_elements = self.layer[text_index]
              
              
              Severity: Minor
              Found in regulations/generator/layers/toc_applier.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 fetch_grouped_history has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def fetch_grouped_history(part):
                  client = api_reader.ApiReader()
                  versions = [
                      version for version in client.regversions(part)['versions']
                      if 'by_date' in version
              Severity: Minor
              Found in regulations/generator/versions.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 test_diffs has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def test_diffs(self):
                      self.driver.get(self.test_url + '/1005-2/2011-11111')
                      html = self.driver.find_element_by_tag_name('html')
                      WebDriverWait(self.driver, 60).until(
                          lambda driver: 'selenium-start' in html.get_attribute('class'))
              Severity: Minor
              Found in regulations/uitests/diff_test.py - About 1 hr to fix

                Function test_diff_toc has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def test_diff_toc(self):
                        """Integration test."""
                        versions = views_diff.Versions('oldold', 'newnew', 'from_ver')
                        old_toc = [{'section_id': '8888-1', 'index': ['8888', '1'],
                                    'is_section':True},
                Severity: Minor
                Found in regulations/tests/views_diff_tests.py - About 1 hr to fix

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

                    initialize: function initialize() {
                      this.dataTables = null;
                  
                      if (Router.hasPushState) {
                        this.listenTo(MainEvents, 'search-results:open', this.openSection);
                  Severity: Minor
                  Found in regulations/static/regulations/js/source/views/main/main-view.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language