Showing 237 of 237 total issues
Avoid deeply nested control flow statements. Open
if ( conv && s.throws ) {
response = conv( response );
} else {
try {
response = conv( response );
Avoid deeply nested control flow statements. Open
if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
setMatched[ i ] = pop.call( results );
}
Avoid deeply nested control flow statements. Open
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " ";
}
Avoid deeply nested control flow statements. Open
if ( nodeType === 9 ) {
if ( ( elem = context.getElementById( m ) ) ) {
// Support: IE, Opera, Webkit
// TODO: identify versions
Avoid deeply nested control flow statements. Open
if ( !selector ) {
push.apply( results, seed );
return results;
}
Function gpa_to_edge_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def gpa_to_edge_data(self, rec: dict) -> list:
"""Return an edge with annotations given a parsed gpa entry.
:param rec: record from gpa iterator
:return:
- 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 elastic_search_query
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def elastic_search_query(
Avoid deeply nested control flow statements. Open
if remap and k2 in remap.keys():
update_properties(remap[k2], v2)
else:
update_properties(k2, v2)
else:
Avoid deeply nested control flow statements. Open
for x in v:
r = self.parse_doc_fields(x, allowed_properties, remap)
for k2, v2 in r.items():
update_properties(k2, v2)
else:
Function result_dict_to_tsv
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def result_dict_to_tsv(result_dict: dict, outfile: str) -> None:
"""Convert a result_dict to a TSV for output."""
with open(outfile, "wt") as f:
# header
f.write("\t".join(result_dict["head"]["vars"]) + "\n")
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
case 39: // right
var nextHref = $('link[rel="next"]').prop('href');
if (nextHref) {
window.location.href = nextHref;
return false;
- 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 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
- 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
Avoid deeply nested control flow statements. Open
if protein in string_to_uniprot_id_map:
uniprot_curie = (
f"UniProtKB:{string_to_uniprot_id_map[protein]}"
)
uniprot_curie = collapse_uniprot_curie(uniprot_curie)
Avoid deeply nested control flow statements. Open
if gene not in seen_genes:
seen_genes.add(gene)
ensemble_gene = f"ENSEMBL:{gene}"
gene_informations = self.gene_info_map[
self.ensembl2ncbi_map[gene]
Function make_holdouts
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def make_holdouts(
Avoid deeply nested control flow statements. Open
if cur_gene_name in linec_split:
#print("found")
found = 1
countORFs = countORFs + 1
Function make_id_mapping_file
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def make_id_mapping_file(
Avoid deeply nested control flow statements. Open
if entity_type == "Gene":
self.make_pharmgkb_gene_node(
fh=node,
this_id=entity_id,
name=entity_name,
Avoid deeply nested control flow statements. Open
if not item:
continue # not xrefs, skip
item = item.strip('"') # remove quotes around each item
Function transform
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def transform(
input_dir: str, output_dir: str, sources: Optional[List[str]] = None
) -> None:
"""Call scripts in kg_covid_19/transform/[source name]/ to transform data.
- 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
Avoid deeply nested control flow statements. Open
if self.key_parsed_ids not in dat:
dat[self.key_parsed_ids] = dict()
dat[self.key_parsed_ids][key] = value