dmyersturnbull/mandos

View on GitHub

Showing 151 of 151 total issues

Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in mandos/search/pubchem/trials_search.py - About 35 mins to fix

    Function export_taxa has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def export_taxa(
    Severity: Minor
    Found in mandos/entry/misc_commands.py - About 35 mins to fix

      Function adjust_dir_name has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def adjust_dir_name(
      Severity: Minor
      Found in mandos/entry/utils/_arg_utils.py - About 35 mins to fix

        Function choose_palette has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def choose_palette(
                cls,
                data: pd.DataFrame,
                col: Optional[str],
                palette: Optional[str],
        Severity: Minor
        Found in mandos/analysis/_plot_utils.py - About 35 mins to fix

        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 _new_conc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _new_conc(self, x: NestedDotDict) -> Optional[HmdbConcentration]:
                specimen = x["biospecimen"]
                # both can be "Not Specified"
                ages = {
                    "Adult": PersonAge.adults,
        Severity: Minor
        Found in mandos/model/apis/hmdb_support/hmdb_data.py - About 35 mins to fix

        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 fetch_properties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def fetch_properties(self, cid: int) -> Mapping[str, Any]:
                url = f"{self._pug}/compound/cid/{cid}/JSON"
                #
                try:
                    matches: NestedDotDict = self._query_json(url)
        Severity: Minor
        Found in mandos/model/apis/querying_pubchem_api.py - About 35 mins to fix

        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_by_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _build_by_name(cls, tax: Iterable[Taxon]) -> Mapping[str, FrozenSet[Taxon]]:
                by_name = defaultdict(set)
                # put these in the right order
                # so that we favor mnemonic, then scientific name, then common name
                for t in tax:
        Severity: Minor
        Found in mandos/model/taxonomy.py - About 35 mins to fix

        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 fetch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def fetch(self, inchikey_or_hmdb_id: str) -> HmdbData:
                logger.debug(f"Downloading HMDB data for {inchikey_or_hmdb_id}")
                # e.g. https://hmdb.ca/metabolites/HMDB0001925.xml
                cid = None
                if inchikey_or_hmdb_id.startswith("HMDB"):
        Severity: Minor
        Found in mandos/model/apis/hmdb_api.py - About 35 mins to fix

        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 str_to has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def str_to(
                cls, type_: Callable[[str], T], nullable: bool = False, flex_type: bool = False
            ) -> Callable[[str], str]:
                def str_to(value: Optional[str]) -> Optional[T]:
                    if value is None and nullable:
        Severity: Minor
        Found in mandos/model/apis/pubchem_support/_nav_fns.py - About 35 mins to fix

        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 list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def list(
                cls,
                lst: Iterable[Any],
                *,
                attr: Union[None, str, Callable[[Any], Any]] = None,
        Severity: Minor
        Found in mandos/entry/utils/_arg_utils.py - About 35 mins to fix

        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 None
        Severity: Major
        Found in mandos/search/pubchem/drugbank_ddi_search.py - About 30 mins to fix

          Function _process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _process(
                  self,
                  compound_id: Optional[str],
                  library: Optional[str],
                  inchi: Optional[str],
          Severity: Minor
          Found in mandos/entry/tools/fillers.py - About 25 mins to fix

          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 accept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def accept(self, target: TargetNode) -> bool:
                  if target.link_reqs is None:
                      # typically for root nodes -- we'll have a self-loop to check, too
                      logger.trace(f"Rejected probable root: {target}")
                      return False
          Severity: Minor
          Found in mandos/model/apis/chembl_support/target_traversal.py - About 25 mins to fix

          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 req_is has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def req_is(cls, type_, nullable: bool = False, then_convert=None) -> Callable[[str], str]:
                  def req_is(value):
                      if nullable and value is None:
                          pass
                      elif not isinstance(value, type_):
          Severity: Minor
          Found in mandos/model/apis/pubchem_support/_nav_fns.py - About 25 mins to fix

          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 cross has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def cross(
                  cls,
                  source_types: Set[TargetType],
                  rel_types: Set[TargetRelType],
                  dest_types: Set[TargetType],
          Severity: Minor
          Found in mandos/model/apis/chembl_support/chembl_target_graphs.py - About 25 mins to fix

          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 _guess_neighbor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _guess_neighbor(self, kind: CoOccurrenceType, neighbor_id: str) -> str:
                  if kind is CoOccurrenceType.chemical:
                      return Codes.PubchemCompoundId(neighbor_id)
                  elif kind is CoOccurrenceType.gene and neighbor_id.startswith("EC:"):
                      return Codes.EcNumber(neighbor_id)
          Severity: Minor
          Found in mandos/model/apis/pubchem_support/pubchem_data.py - About 25 mins to fix

          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_by_id_or_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_by_id_or_name(self, item: Union[int, str, Taxon]) -> FrozenSet[Taxon]:
                  """
                  Gets all taxa that match an ID or name.
                  """
                  if isinstance(item, Taxon):
          Severity: Minor
          Found in mandos/model/taxonomy.py - About 25 mins to fix

          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 __truediv__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def __truediv__(
                  self,
                  keys: Union[
                      Sequence[Union[None, str, Callable[[Any], Any]]], FilterFn, Callable[[List[T]], Any]
                  ],
          Severity: Minor
          Found in mandos/model/apis/pubchem_support/_nav.py - About 25 mins to fix

          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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def load(cls, data: NestedDotDict) -> Settings:
                  extra_default_keys = dict(defaults)
          
                  def get(s: str, t: Type[T]) -> T:
                      if s in extra_default_keys:  # could be accessed more than once
          Severity: Minor
          Found in mandos/model/settings.py - About 25 mins to fix

          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_suffix has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def _check_suffix(cls, suffix, suffixes):
                  if suffixes is not None and callable(suffixes):
                      try:
                          suffixes(suffix)  # make sure it's ok
                      except FilenameSuffixError:
          Severity: Minor
          Found in mandos/entry/utils/_arg_utils.py - About 25 mins to fix

          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

          Severity
          Category
          Status
          Source
          Language