Showing 14 of 16 total issues
Function _run_metadata_migration
has a Cognitive Complexity of 29 (exceeds 10 allowed). Consider refactoring. Open
def _run_metadata_migration(
metadata_migration: Callable[[dict], MigrationResult],
use_upload_jobs_table: bool,
gcs_tasks: RollbackableQueue,
session: Session,
- 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
DownloadableFiles
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class DownloadableFiles(CommonColumns):
"""
Store required fields from:
https://github.com/CIMAC-CIDC/cidc-schemas/blob/master/cidc_schemas/schemas/artifacts/artifact_core.json
"""
Function _change_download_permissions
has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring. Open
def _change_download_permissions(
trial_id: str, upload_type: str, grant: bool, session: Session
) -> None:
"""
Allows for widespread granting/revoking of existing download permissions in GCS ACL
- 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_optional_uuid_recursive
has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring. Open
def _remove_optional_uuid_recursive(target: dict, uuid: str):
"""
If target contains an item : dict with {"upload_placeholder":uuid}, removes that item and returns the modified target
If no such item is found, continues recursively as depth first search
If the uuid is never found, returns the target unchanged
- 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 inner
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def inner(f):
@wraps(f)
def wrapped(*args, **kwargs):
logger.info(f"upload_handler({f.__name__}) started")
template, xlsx_file = extract_schema_and_xlsx(allowed_types)
- 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 unmarshal_request
has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring. Open
def unmarshal_request(schema: BaseSchema, kwarg_name: str, load_sqla: bool = True):
"""
Generate a decorator that will load and validate the JSON body of
the current request object as an instance of `schema` and pass
the loaded instance to the decorated function as a keyword argument
- 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 insert
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def insert(
self,
session: Session,
commit: bool = True,
) -> 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
has 8 arguments (exceeds 6 allowed). Consider refactoring. Open
def create(
Function create_from_blob
has 7 arguments (exceeds 6 allowed). Consider refactoring. Open
def create_from_blob(
Function is_valid_transition
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring. Open
def is_valid_transition(
cls, current: str, target: str, is_manifest: bool = False
) -> bool:
"""
Enforce logic about which state transitions are valid. E.g.,
- 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 too many return
statements within this function. Open
return True
Function authorize
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
def authorize(
user: Users, allowed_roles: List[str], resource: str, method: str
) -> bool:
"""Check if the current user is authorized to act on the current request's resource.
Raises Unauthorized
- 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 _encode_and_publish
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
def _encode_and_publish(content: str, topic: str) -> Future:
"""Convert `content` to bytes and publish it to `topic`."""
pubsub_publisher = pubsub.PublisherClient()
topic = pubsub_publisher.topic_path(GOOGLE_CLOUD_PROJECT, topic)
data = bytes(content, "utf-8")
- 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 build_file_filter
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
def build_file_filter(
trial_ids: List[str] = [], facets: List[List[str]] = [], user: Users = None
) -> Callable[[Query], Query]:
"""
Build a file filter function based on the provided parameters. The resultant
- 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"