eregs/regulations-site

View on GitHub

Showing 86 of 405 total issues

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

  updateLinks: function updateLinks(initialSection) {
    let section = initialSection;
    let prefix = window.APP_PREFIX;
    if (typeof prefix !== 'undefined' && prefix.substr(prefix.length - 1) !== '/') {
      prefix += '/';
Severity: Minor
Found in regulations/static/regulations/js/source/views/drawer/history-view.js - 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 add_nodes_to_tree has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def add_nodes_to_tree(self, original, adds):
        """ Add all the nodes from new_nodes into the original tree. """
        tree_hash = tree_builder.build_tree_hash(original)
        for node in tree_hash.values():
            self.set_child_labels(node)
Severity: Minor
Found in regulations/generator/layers/diff_applier.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 footer_nav has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def footer_nav(self, label, toc, versions):
        nav = {}
        for idx, toc_entry in enumerate(toc):
            if toc_entry['section_id'] != label:
                continue
Severity: Minor
Found in regulations/views/diff.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 make_preamble_nav has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def make_preamble_nav(nodes, depth=1, max_depth=3):
    """Generate NavItems specific to a notice's preamble.
    :type nodes: iterable of Node (a dict)
    :param int depth: Current nesting depth of navigation elements
    :param int max_depth: We'll stop processing once we reach a certain depth
Severity: Minor
Found in fr_notices/navigation.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 set_child_labels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def set_child_labels(self, node):
        """As we display removed, added, and unchanged nodes, the children of
        a node will contain all three types. Pull the 'child_ops' data to
        derive the correct order of these combined children"""
        instructs = self.diff.get('-'.join(node['label']), {})
Severity: Minor
Found in regulations/generator/layers/diff_applier.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 process_node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def process_node(self, node, indexes=None):
        """Every node passes through this function on the way to being
        rendered. Importantly, this adds the `marked_up` field, which contains
        the HTML version of node's text (after applying all relevant
        layers) and the `template_name` field, which defines how this node
Severity: Minor
Found in regulations/generator/html_builder.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 set has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  set: function set(sectionId, sectionValue) {
    const cached = this.has(sectionId);
    let section;

    if (typeof sectionId !== 'undefined' && !(_.isEmpty(sectionId))) {
Severity: Minor
Found in regulations/static/regulations/js/source/models/meta-model.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

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

    def __new__(cls, url, title, markup_id, children=None, category=None,
Severity: Minor
Found in fr_notices/navigation.py - About 45 mins to fix

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

      setSection: function setSection(section, tocId, indexes, label, blank) {
    Severity: Minor
    Found in regulations/static/regulations/js/source/views/comment/comment-view.js - About 35 mins to fix

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

          def test_get_context_data(self, nav, CFRHTMLBuilder, filter_by_subterp,
      Severity: Minor
      Found in regulations/tests/views_partial_interp_tests.py - About 35 mins to fix

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

        def redirect_by_date(request, label_id, year, month, day):
        Severity: Minor
        Found in regulations/views/redirect.py - About 35 mins to fix

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

          def layers(layer_names, doc_type, label_id, sectional=False, version=None):
          Severity: Minor
          Found in regulations/generator/generator.py - About 35 mins to fix

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

              write: function write(section, tocId, indexes, label, parentEl) {
            Severity: Minor
            Found in regulations/static/regulations/js/source/views/main/preamble-view.js - About 35 mins to fix

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

                  def regtext_changes_context(cls, amendments, version_info, label_id,
              Severity: Minor
              Found in regulations/views/preamble.py - About 35 mins to fix

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

                    def _input_files(self):
                        """Fetch all of the static files from the installed apps. Yield them
                        as pairs of (path, file)"""
                        files_seen = set()
                        pairs = (pr for finder in get_finders() for pr in finder.list([]))
                Severity: Minor
                Found in regulations/management/commands/compile_frontend.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 route has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  route: function route(options) {
                    if (Router.hasPushState && typeof options.noRoute === 'undefined') {
                      let url = this.url;
                
                            // if a hash has been passed in
                Severity: Minor
                Found in regulations/static/regulations/js/source/views/main/child-view.js - 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 order_diff_versions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def order_diff_versions(label_id, version, new_version):
                    # Re-order if needed - History is sorted in reverse chronological order
                    for major_version in fetch_grouped_history(label_id.split('-')[0]):
                        for notice in major_version['notices']:
                            # Hit the "old" version first, meaning it's not actually the old
                Severity: Minor
                Found in regulations/views/redirect.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 process_node has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def process_node(self, node, indexes=None):
                        """Overrides with custom, additional processing"""
                        super(CFRHTMLBuilder, self).process_node(node, indexes=indexes)
                        if 'marked_up' in node:
                            node['marked_up'] = self.section_space(node['marked_up'])
                Severity: Minor
                Found in regulations/generator/html_builder.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 modify_interp_node has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def modify_interp_node(self, node):
                        """Add extra fields which only exist on interp nodes"""
                        #   ['105', '22', 'Interp'] => section header
                        node['section_header'] = len(node['label']) == 3
                
                
                Severity: Minor
                Found in regulations/generator/html_builder.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 modified_deleted_sections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                def modified_deleted_sections(diff):
                    modified, deleted = set(), set()
                    for label, diff_value in six.iteritems(diff):
                        label = tuple(label.split('-'))
                        if 'Interp' in label:
                Severity: Minor
                Found in regulations/views/diff.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

                Severity
                Category
                Status
                Source
                Language