Showing 274 of 290 total issues
Function gather_schema_changes
has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring. Open
def gather_schema_changes(schema1, schema2, attribute_filter=None):
""" Compare two schemas section by section, generating a changelog
Parameters:
schema1 (HedSchema): The first schema to be compared.
- 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 _get_tag_equivalent_to
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
def _get_tag_equivalent_to(self, tag_entry):
subclass = self._get_subclass_of(tag_entry)
attribute_types = {
"object": "some",
- 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
File error_reporter.py
has 516 lines of code (exceeds 300 allowed). Consider refactoring. Open
"""
Support functions for reporting validation errors.
You can scope the formatted errors with calls to push_error_context and pop_error_context.
"""
Function check_attributes
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
def check_attributes(self):
"""Returns issues from validating known attributes in all sections"""
issues_list = []
for section_key in HedSectionKey:
self.error_handler.push_error_context(ErrorContext.SCHEMA_SECTION, str(section_key))
- 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 _validate_refs
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def _validate_refs(self, sidecar, error_handler):
possible_column_refs = sidecar.all_hed_columns
if "HED" not in possible_column_refs:
possible_column_refs.append("HED")
- 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
File summarize_hed_tags_op.py
has 402 lines of code (exceeds 300 allowed). Consider refactoring. Open
""" Summarize the HED tags in collection of tabular files. """
import os
import numpy as np
from hed.models.tabular_input import TabularInput
from hed.tools.analysis.hed_tag_counts import HedTagCounts
Function validate
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, sidecar, extra_def_dicts=None, name=None, error_handler=None):
"""Validate the input data using the schema
Parameters:
sidecar (Sidecar): Input data to be validated.
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
def __str__(self):
output_str = "("
if self.left:
output_str += str(self.left)
output_str += " " + str(self.token)
- Read upRead up
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 78.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
def __str__(self):
output_str = "("
if self.left:
output_str += str(self.left)
output_str += " " + str(self.token)
- Read upRead up
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 78.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function compare_schemas
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def compare_schemas(schema1, schema2, attribute_filter=HedKey.InLibrary, sections=(HedSectionKey.Tags,)):
""" Compare two schemas section by section.
The function records matching entries, entries present in one schema but not in the other, and unequal entries.
- 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 split_hed_string
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def split_hed_string(hed_string):
""" Split a HED string into delimiters and tags.
Parameters:
hed_string (str): The HED string to split.
- 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 check_tag_level_issue
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def check_tag_level_issue(original_tag_list, is_top_level, is_group):
""" Report tags incorrectly positioned in hierarchy.
Top-level groups can contain definitions, Onset, etc. tags.
- 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 merge_and_groups
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def merge_and_groups(groups1, groups2):
"""Finds any shared results
Parameters:
groups1(list): a list of search results
- 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 split_into_groups
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def split_into_groups(hed_string, hed_schema, def_dict=None):
""" Split the HED string into a parse tree.
Parameters:
hed_string (str): A HED string consisting of tags and tag groups to be processed.
- 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 _handle_grouping_op
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def _handle_grouping_op(self):
next_token = self._next_token_is(
[Token.LogicalGroup, Token.DescendantGroup, Token.ExactMatch])
if next_token == Token.LogicalGroup:
expr = self._handle_or_op()
- 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 hed_tag_error
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def hed_tag_error(error_type, default_severity=ErrorSeverity.ERROR, has_sub_tag=False, actual_code=None):
""" Decorator for errors in error handler or inherited classes.
Parameters:
error_type (str): A value from error_types or optionally another value.
- 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
ColumnMapper
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class ColumnMapper:
""" Mapping of a base input file columns into HED tags.
Notes:
- All column numbers are 0 based.
File hed_cache.py
has 340 lines of code (exceeds 300 allowed). Consider refactoring. Open
"""Infrastructure for caching HED schema from remote repositories."""
import shutil
import os
File annotation_util.py
has 338 lines of code (exceeds 300 allowed). Consider refactoring. Open
""" Utilities to facilitate annotation of events in BIDS. """
import io
import re
Function _check_other_attributes
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def _check_other_attributes(entry1, entry2, tag, section_key, change_dict):
"""Compare non specialized attributes"""
already_checked_attributes = [HedKey.RelatedTag, HedKey.SuggestedTag, HedKey.ValueClass, HedKey.UnitClass]
unique_keys = set(entry1.attributes.keys()).union(entry2.attributes.keys())
if section_key == HedSectionKey.Tags:
- 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"