Showing 59 of 59 total issues
File template.py
has 1001 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
"""The underlying data representation of an assay or shipping manifest template."""
import os
Function _convert_api_to_template
has a Cognitive Complexity of 94 (exceeds 10 allowed). Consider refactoring. Open
def _convert_api_to_template(name: str, schema: dict, assay_schema: dict):
# import here to avoid circular dependence where prism imports Template
from .prism.merger import InvalidMergeTargetException
# so many different ways of writing it
- 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 generate_docs.py
has 702 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
from collections import OrderedDict
from copy import deepcopy
import jinja2
import json
File pipelines.py
has 685 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Analysis pipeline configuration generators."""
from collections import defaultdict
from datetime import datetime
from io import BytesIO
import logging
Function _validate_worksheet
has a Cognitive Complexity of 54 (exceeds 10 allowed). Consider refactoring. Open
def _validate_worksheet(self, worksheet_name: str, ws_schema: dict) -> List[str]:
"""Validate rows in a worksheet, returning a list of validation error messages."""
self.visited_fields.clear()
# If no worksheet is found, return only that error.
- 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 _first_in_context
has a Cognitive Complexity of 53 (exceeds 10 allowed). Consider refactoring. Open
def _first_in_context(path: list, context: dict):
"""
For matching a file path to its nearest equivalent key in a schema context
Recursive to try for more specific, more complex 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 parse_clinical
has a Cognitive Complexity of 46 (exceeds 10 allowed). Consider refactoring. Open
def parse_clinical(file: BinaryIO) -> dict:
"""
Parses the given clinical file to extract a list of participant IDs.
By convention the first column should be "cimac_part_id" for files containing
clinical data keyed to a specific participant. All tabs in each XLSX need to be checked
- 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 core.py
has 403 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Build metadata dictionaries from Excel files."""
import logging
import base64
import hmac
from typing import List, Tuple, Union
File template_writer.py
has 383 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
"""Defines the `XlTemplateWriter` class for writing `Template`s to Excel templates."""
import logging
File json_validation.py
has 380 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- encoding: utf-8 -*-
"""Tools for performing validations based on json schemas"""
import os
Function prismify
has a Cognitive Complexity of 37 (exceeds 10 allowed). Consider refactoring. Open
def prismify(
xlsx: XlTemplateReader,
template: Template,
schema_root: str = SCHEMA_DIR,
debug: bool = False,
- 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 _map_refs
has a Cognitive Complexity of 34 (exceeds 10 allowed). Consider refactoring. Open
def _map_refs(node: dict, on_refs: Callable[[str], dict]) -> dict:
"""
Apply `on_refs` to all nodes with `$ref`, returning node with refs replaced
with results of the function call.
- 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 _update_definition_from_merge_pointer
has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring. Open
def _update_definition_from_merge_pointer(
self,
context_pointer: str,
definition: dict,
) -> dict:
- 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 utils.py
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os
import jsonschema
from typing import Any, Dict, Iterable, List, Set, Tuple
from cidc_schemas.constants import SCHEMA_DIR
Function parse_npx
has a Cognitive Complexity of 29 (exceeds 10 allowed). Consider refactoring. Open
def parse_npx(xlsx: BinaryIO) -> dict:
"""
Parses the given NPX file from olink to extract a list of sample IDs.
If the file is not valid NPX but still xlsx the function will
return a dict containing an empty list. Sample IDs not conforming to the CIMAC 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
File migrations.py
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
from copy import deepcopy
from typing import NamedTuple, Dict
from .prism.core import _ENCRYPTED_FIELD_LEN, _encrypt
Function upgrade
has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring. Open
def upgrade(cls, metadata: dict, *args, **kwargs) -> MigrationResult:
# these are removal, so cannot downgrade later
metadata.pop("collection_event_list", None)
for partic in metadata.get("participants", []):
- 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 unprism.py
has 290 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Tools from extracting information from trial metadata blobs."""
from io import StringIO, BytesIO
from typing import Callable, Dict, List, NamedTuple, Optional, Union
import pandas as pd
Function from_excel
has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring. Open
def from_excel(xlsx_path: Union[str, BinaryIO]):
"""
Initialize an Excel template reader from an excel file.
Arguments:
- 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 _pair_all_samples
has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring. Open
def _pair_all_samples(
self, partic_map: Dict[str, Dict[str, Dict[str, str]]]
) -> List[_PairingEntry]:
"""
(Semi)automated pairing of tumor and normal samples
- 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"