Showing 86 of 405 total issues
Function filter_by_subterp
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def filter_by_subterp(nodes, subterp_label, version):
"""Given an interp node (e.g. a node with label ['1005', 'Interp']),
remove all irrelevant sub-nodes. Note that stripping out nodes is more
efficient than compiling nodes when API calls are involved. We use
takewhile and dropwhile in case extra, non-node interpretations are in
- Read upRead up
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 initialize
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialize: function initialize(options) {
this.options = options;
this.$context = this.$el.find('.comment-context');
this.$contextSectionLabel = this.$el.find('.comment-context-section');
Function find_label_in_sxs
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def find_label_in_sxs(sxs_list, label_id, fr_page=None):
""" Given a tree of SXS sections, find a non-empty sxs that matches
label_id. Some notices may have the same label appearing multiple times;
use fr_page to distinguish, defaulting to the first"""
- Read upRead up
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
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def fetch(self, citation, version, sectional):
key = (tuple(citation), version, sectional)
if key not in self.rev_cache:
url = ''
- Read upRead up
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 convert_to_python
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def convert_to_python(data):
"""Convert raw data (e.g. from json conversion) into the appropriate
Python objects"""
if isinstance(data, six.string_types):
# Dates
- Read upRead up
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 nav_sections
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def nav_sections(current, version):
labels = get_labels(current)
reg_part = labels[0]
toc = fetch_toc(reg_part, version, flatten=True)
for idx, el in enumerate(toc):
- Read upRead up
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 diff_toc
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def diff_toc(versions, old_toc, diff):
# We work around Subparts in the TOC for now.
compiled_toc = extract_sections(old_toc)
for node in (v['node'] for v in diff.values() if v['op'] == 'added'):
- Read upRead up
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 termLinkHandler
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
termLinkHandler: function termLinkHandler(e) {
e.preventDefault();
const $link = $(e.target);
const defId = $link.data('definition');
Function updateLinks
has 30 lines of code (exceeds 25 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 += '/';
Function initDependencies
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
initDependencies: function initDependencies() {
const self = this;
self.$el.find('[data-depends-on]').each((idx, elm) => {
const $elm = $(elm);
const $select = selfOrChild($elm, 'select');
Function checkActiveSection
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
checkActiveSection: function checkActiveSection() {
$.each(this.$sections, (idx, $section) => {
const previousSection = activeParagraph(storage()).paragraph;
if ($section.offset().top + WAYFINDER_SCROLL_OFFSET >= $(window).scrollTop()) {
if (_.isEmpty(previousSection) || (previousSection !== $section.id)) {
- Read upRead up
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 apply_diff_changes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def apply_diff_changes(self, original, diff_list):
"""Account for modified text"""
self.deconstruct_text(original)
for d in diff_list:
if d[0] == self.INSERT:
- Read upRead up
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_relevant_trees
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def fetch_relevant_trees(self, http_client):
"""If using subterps, we might be getting a list of relevant trees
rather than a single node."""
is_interp = 'Interp' in self.label_parts
is_complex = set(['Subpart', 'Appendices']) & set(self.label_parts)
- Read upRead up
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 remove_dirs
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def remove_dirs(self):
"""Remove existing output dirs"""
if os.path.exists(self.TARGET_DIR):
shutil.rmtree(self.TARGET_DIR)
# Delete everything in BUILD_DIR except node_modules, which we use for
- Read upRead up
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 sanitize_fields
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_fields(body):
""" Validate fields against the document metadata.
Remove any extra fields that are not in the document metadata.
Special treatment for 'assembled_comment' - allow to pass through
as it holds the text form of the entire submission
- Read upRead up
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 redirect_by_date_str
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def redirect_by_date_str(request, label_id, date_str):
"""If a user requests a date as the version, find the version which was
current as of that date. date_str is an ISO date string, but may have a
2-digit year"""
date_versions = []
- Read upRead up
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 _l2t_section
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _l2t_section(label, include_section, include_marker):
"""Helper function converting section labels to text. Assumes
_l2t_subterp, _l2t_interp, and _l2t_appendix failed"""
if include_marker:
marker = u'§ '
- Read upRead up
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_toc_sect_appendix
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_toc_sect_appendix(self):
data = {'title': u'§ 1026.1 - Authority', 'index': ['1026', '1']}
result = toc.toc_sect_appendix(data, [])
self.assertEqual(u'1026.1', result['label'])
self.assertEqual('Authority', result['sub_label'])
Function footer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def footer(preamble_toc, cfr_toc, full_id):
"""Generate "navigation" context which allows the user to move between
sections in the footer"""
items = preamble_toc + cfr_toc
nav = {'previous': None, 'next': None, 'page_type': 'preamble-section'}
- Read upRead up
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 appendix_supplement
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def appendix_supplement(data):
"""Handle items pointing to an appendix or supplement"""
node_type = node_types.type_from_label(data['index'])
if len(data['index']) == 2 and node_type in (node_types.APPENDIX,
node_types.INTERP):
- Read upRead up
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"