datalad/datalad-neuroimaging

View on GitHub

Showing 25 of 36 total issues

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

    def process(self, match):
        """Produce the next token and bit of text.

        Interprets the ANSI code (which may be a color code or some other
        code), changing the lexer state and producing a new token. If it's not
Severity: Minor
Found in docs/utils/pygments_ansi_color.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 _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 get_metadata has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def get_metadata(self, dataset, content):
        if not content:
            return {}, []
        contentmeta = []
        log_progress(
Severity: Minor
Found in datalad_neuroimaging/extractors/nifti1.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

Function cmdline_example_to_rst has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def cmdline_example_to_rst(src, out=None, ref=None):
    if out is None:
        from six.moves import StringIO
        out = StringIO()

Severity: Minor
Found in formatters.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

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

Function _get_cnmeta has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_cnmeta(self, bids):
        # TODO any custom handling of participants infos should eventually
        # be done by pybids in one way or another
        path_props = {}
        participants_fname = opj(self.ds.path, 'participants.tsv')
Severity: Minor
Found in datalad_neuroimaging/extractors/bids.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 yield_participant_info has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def yield_participant_info(bids):
        for bidsvars in bids.get_collections(
                level='dataset')[0].to_df().to_dict(orient='records'):
            props = dict(id=assure_unicode(bidsvars.pop('subject')))
            for p in bidsvars:
    Severity: Minor
    Found in datalad_neuroimaging/extractors/bids.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 get_metadata has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_metadata(self, dataset, content):
            imgseries = {}
            imgs = {}
            log_progress(
                lgr.info,
    Severity: Minor
    Found in datalad_neuroimaging/extractors/dicom.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 __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 get_required_content has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_required_content(self):
            # TODO: logging
            # bids_dir = _find_bids_root(self.dataset.path)
            for f in REQUIRED_BIDS_FILES:
                f_abs = self.dataset.pathobj / f
    Severity: Minor
    Found in datalad_neuroimaging/extractors/bids_dataset.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 color_tokens has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def color_tokens(fg_colors, bg_colors):
        """Return color tokens for a given set of colors.
    
        Pygments doesn't have a generic "color" token; instead everything is
        contextual (e.g. "comment" or "variable"). That doesn't make sense for us,
    Severity: Minor
    Found in docs/utils/pygments_ansi_color.py - About 1 hr 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_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def _convert_value(v):
        t = type(v)
        if v is None:
            cv = v
        elif t in (int, float):
    Severity: Minor
    Found in datalad_neuroimaging/extractors/dicom.py - About 1 hr 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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self,
    Severity: Major
    Found in formatters.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                                  if fg_color:
                                      self.fg_color = fg_color
                                  elif bg_color:
                                      self.bg_color = bg_color
                                  elif value == 1:
      Severity: Major
      Found in docs/utils/pygments_ansi_color.py - About 45 mins to fix

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

            def _format_action_invocation(self, action):
                if not action.option_strings:
                    metavar, = self._metavar_formatter(action, action.dest)(1)
                    return metavar
        
        
        Severity: Minor
        Found in formatters.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
          Severity
          Category
          Status
          Source
          Language