Showing 111 of 113 total issues
Function get_resources_handles
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def get_resources_handles(client, username=None, password=None):
"""Get BEL Resources arangodb handle"""
(username, password) = get_user_credentials(username, password)
- 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
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def convert(ast):
"""Convert BEL1 AST Function to BEL2 AST Function"""
if ast and ast.type == "Function":
# Activity function conversion
- 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 scripts.py
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Standard Library
import gzip
import json
import re
import sys
Function parse_belscript
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def parse_belscript(lines):
"""Lines from the BELScript - can be an iterator or list
yields Nanopubs in nanopubs_bel-1.0.0 format
"""
- 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_sections
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def validate_sections(nanopub: NanopubR, validation_level: str = "complete") -> NanopubR:
"""Validate Nanopub sections"""
if not isinstance(nanopub, dict):
nanopub = nanopub.dict(exclude_unset=True, exclude_none=True)
- 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_annotations
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def validate_annotations(annotations: List[dict], validation_level: str):
"""Validate annotations
Args:
annotations (List[dict]): List of annotation objects
- 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 read_nanopubs
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def read_nanopubs(fn: str) -> Iterable[Mapping[str, Any]]:
"""Read file and generate nanopubs
If filename has *.gz, will read as a gzip file
If filename has *.jsonl*, will parsed as a JSONLines file
- 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 __init__
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def __init__(
self,
assertion: AssertionStr = None,
subject: Optional[Function] = None,
relation: Optional[Relation] = None,
- 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 create_email_body_for_update_resources
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def create_email_body_for_update_resources(results):
"""Create email message body for update_resources"""
failures = [url for url in results if results[url]["state"] == "Failed"]
warnings = [url for url in results if results[url]["state"] == "Warning"]
- 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 batch_load_docs
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def batch_load_docs(db, doc_iterator, on_duplicate: str = "replace"):
"""Batch load documents
Args:
db: ArangoDB client database handle
- 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
Consider simplifying this complex logical expression. Open
if len(self.args) == 1 and self.args[0].type == "Function":
self.subject = self.args[0]
# Normal SRO BEL assertion
elif (
len(self.args) == 3
Function update_resources
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def update_resources(urls: List[str] = None, force: bool = False, email: str = None):
"""Update bel resources
Reads the arangodb resources_metadata objects to figure out what bel resource urls to process
unless a url is provided to download (at which point it will be added to resources_metadata on
- 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 enhance.py
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Enhance the BEL Specification YAML file for easier use by BEL package"""
# Standard Library
import copy
import re
from typing import Any, List, Mapping
File belscripts.py
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
"""
Process belscripts content into nanopubs_bel-1.0.0 format for use in BEL.bio
Function orthologs_iterator
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def orthologs_iterator(fo, version, statistics: Mapping):
"""Ortholog node and edge iterator
NOTE: the statistics dict works as a side effect since it is passed as a reference!!!
"""
- 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 terms_iterator_for_elasticsearch
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def terms_iterator_for_elasticsearch(f: IO, index_name: str, metadata: dict):
"""Add index_name to term documents for bulk load"""
species_list = settings.BEL_FILTER_SPECIES
- 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 find_strings
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def find_strings(assertion_str, components):
"""Find str_args and unknown strings"""
str_spans: List[Span] = []
- 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 process_definition
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def process_definition(line, nanopubs_metadata):
"""Process DEFINE line in BEL script"""
matches = re.match('DEFINE\s+(\w+)\s+(\w+)\s+AS\s+URL\s+"(.*?)"\s*$', line)
if matches:
- 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
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, errors: List[ValidationError] = None):
"""Validate BEL Function"""
if errors is None:
errors = []
- 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 load_terms
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def load_terms(
f: IO, metadata: dict, force: bool = False, resource_download_url: Optional[str] = None
):
"""Load terms into Elasticsearch and ArangoDB
- 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"