datalad/datalad-neuroimaging

View on GitHub
datalad_neuroimaging/bids2scidata.py

Summary

Maintainability
F
3 days
Test Coverage

Function _describe_file has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

def _describe_file(dsmeta, fmeta):
    meta = getprop(fmeta, ['metadata'], {})
    bidsmeta = getprop(meta, ['bids'], {})
    suffix = getprop(bidsmeta, ['suffix'], None)
    if suffix is None:
Severity: Minor
Found in datalad_neuroimaging/bids2scidata.py - About 6 hrs 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_assay_df has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def _get_assay_df(
        dsmeta,
        modality, protocol_ref, files, file_descr,
        repository_info=None):
    if not repository_info:
Severity: Minor
Found in datalad_neuroimaging/bids2scidata.py - About 4 hrs 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 convert has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def convert(
        dsmeta,
        filemeta,
        output_directory,
        repository_info=None):
Severity: Minor
Found in datalad_neuroimaging/bids2scidata.py - About 3 hrs 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

File bids2scidata.py has 533 lines of code (exceeds 500 allowed). Consider refactoring.
Open

# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 noet:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
#   See COPYING file distributed along with the datalad package for the
Severity: Major
Found in datalad_neuroimaging/bids2scidata.py - About 2 hrs to fix

    Function __call__ has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(repo_name, repo_accession, repo_url, path=None, output=None, dataset=None):
            # we need this resource file, no point in starting without it
            default_path = opj(dirname(datalad_neuroimaging.__file__), 'resources', 'isatab',
                    'scidata_bids_investigator.txt')
            itmpl_path = cfg.obtain(
    Severity: Minor
    Found in datalad_neuroimaging/bids2scidata.py - About 2 hrs 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 _gather_protocol_parameters_from_df has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _gather_protocol_parameters_from_df(df, protocols):
        params = set()
        protos = None
        for i, col in enumerate(list(df.columns) + ['Protocol REF']):
            if col == 'Protocol REF':
    Severity: Minor
    Found in datalad_neuroimaging/bids2scidata.py - About 2 hrs 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 split_term_source_accession has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def split_term_source_accession(val):
        if val is None:
            return '', ''
        if not r_url.match(val):
            # no URL
    Severity: Minor
    Found in datalad_neuroimaging/bids2scidata.py - About 45 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_assay_df has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _get_assay_df(
    Severity: Minor
    Found in datalad_neuroimaging/bids2scidata.py - About 45 mins to fix

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

          def __call__(repo_name, repo_accession, repo_url, path=None, output=None, dataset=None):
      Severity: Minor
      Found in datalad_neuroimaging/bids2scidata.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return '', val
        Severity: Major
        Found in datalad_neuroimaging/bids2scidata.py - About 30 mins to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              for l in ('rec', 'recording'):
                  if l in bidsmeta:
                      info['Parameter Value[recording label]'] = bidsmeta[l]
          Severity: Minor
          Found in datalad_neuroimaging/bids2scidata.py and 1 other location - About 50 mins to fix
          datalad_neuroimaging/bids2scidata.py on lines 240..242

          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 36.

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              for l in ('acq', 'acquisition'):
                  if l in bidsmeta:
                      info['Parameter Value[acquisition label]'] = bidsmeta[l]
          Severity: Minor
          Found in datalad_neuroimaging/bids2scidata.py and 1 other location - About 50 mins to fix
          datalad_neuroimaging/bids2scidata.py on lines 237..239

          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 36.

          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

          Further Reading

          There are no issues that match your filters.

          Category
          Status