CLOSER-Cohorts/archivist

View on GitHub

Showing 2,584 of 2,584 total issues

File instrument.rb has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Importers::XML::DDI
  class Instrument < DdiImporterBase
    def initialize(thing, options = {})
      if thing.is_a? String
        @doc = open(thing) { |f| Nokogiri::XML(f) }
Severity: Minor
Found in lib/importers/xml/ddi/instrument.rb - About 2 hrs to fix

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

        {!dataLoaded
        ? <Loader />
        : <SequenceItem instrumentId={instrumentId} type={'CcSequence'} id={sequence.children[0].id} title={sequence.children[0].label} children={sequence.children[0].children}/>
      }
Severity: Major
Found in react/src/pages/InstrumentView.js and 1 other location - About 2 hrs to fix
react/src/pages/InstrumentMap.js on lines 776..779

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

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

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

        {!dataLoaded
        ? <Loader />
        : <SequenceItem instrumentId={instrumentId} type={'CcSequence'} id={sequence.children[0].id} title={sequence.children[0].label} children={sequence.children[0].children}/>
      }
Severity: Major
Found in react/src/pages/InstrumentMap.js and 1 other location - About 2 hrs to fix
react/src/pages/InstrumentView.js on lines 552..555

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

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

Cyclomatic complexity for safe_params is too high. [17/6]
Open

  def safe_params
    # The params from Angular use :codes in the params array, we
    # tranform these into params that comply with the params expected
    # by nested attributes using accepts_nested_attributes for the codes
    # and their nested categories.

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Function buildInstrumentBreadcrumbs has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const buildInstrumentBreadcrumbs = () => {
    const paramsFromPath = () => {
      const capturingRegex = `/instruments\\/${instrumentId}\\/(?<type>build|map)\/?(?<subtype>question_grids|question_items|response_domains|code_lists|constructs)?\/?`;
      const found = location.pathname.match(new RegExp(capturingRegex));
      return get(found, 'groups',{})
Severity: Major
Found in react/src/components/BreadcrumbBar.js - About 2 hrs to fix

Function UserForm has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const UserForm = (props) => {
  const {user, onChange, path, onDelete} = props;

  const dispatch = useDispatch();
  const classes = useStyles();
Severity: Major
Found in react/src/components/UserForm.js - About 2 hrs to fix

Function AdminUserForm has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const AdminUserForm = (props) => {
  const {user} = props;

  const dispatch = useDispatch();
  const classes = useStyles();
Severity: Major
Found in react/src/components/AdminUserForm.js - About 2 hrs to fix

Function ResponseDomainDatetimeForm has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const ResponseDomainDatetimeForm = (props) => {
  const {responseDomain, instrumentId, instrument} = props;

  const dispatch = useDispatch();
  const classes = useStyles();
Severity: Major
Found in react/src/components/ResponseDomainDatetimeForm.js - About 2 hrs to fix

Method V3_2 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def V3_2(qgrid_id)
      @klass = ::QuestionGrid

      super do |qgrid, qg|

Severity: Minor
Found in lib/exporters/xml/ddi/question_grid.rb - 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

Method import has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  def import(options = {})
    variable_ids_to_delete = @object.variables.pluck(:id)
    set_import_to_running
    vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic)
    @doc.each do |dataset, v, t|
Severity: Minor
Found in lib/importers/txt/mapper/topic_v.rb - 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

File Dashboard.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useEffect } from 'react';
import { useSelector } from 'react-redux'
import { get } from 'lodash'
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
Severity: Minor
Found in react/src/components/Dashboard.js - About 2 hrs to fix

Function QuestionGridListItem has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const QuestionGridListItem = (props) => {
  const { item, instrumentId } = props
  const classes = useStyles();

  const title = (isEmpty(item.question)) ? item.label : item.question.literal
Severity: Major
Found in react/src/pages/InstrumentMap.js - About 2 hrs to fix

Function AdminInstrumentForm has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const AdminInstrumentForm = (props) => {
  const {instrument, datasets} = props;

  const [signedOff, setSignedOff] = React.useState(instrument.signed_off);

Severity: Major
Found in react/src/components/AdminInstrumentForm.js - About 2 hrs to fix

Method has too many lines. [40/30]
Open

  def safe_params
    # The params from Angular use :codes in the params array, we
    # tranform these into params that comply with the params expected
    # by nested attributes using accepts_nested_attributes for the codes
    # and their nested categories.

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [40/30]
Open

  def import(options = {})
    variable_ids_to_delete = @object.variables.pluck(:id)
    set_import_to_running
    vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic)
    @doc.each do |dataset, v, t|
Severity: Minor
Found in lib/importers/txt/mapper/topic_v.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Function DatasetView has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DatasetView = (props) => {
  const { dataset } = props;

  const classes = useStyles();

Severity: Major
Found in react/src/pages/AdminDatasetView.js - About 2 hrs to fix

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

                    case 'CcSequence':
                      return (
                          <StyledListItem className={classes.nested}>
                            <SequenceItem instrumentId={instrumentId} id={child.id} type={child.type} title={child.type} children={get(child,'children',[])} />
                          </StyledListItem>)
Severity: Major
Found in react/src/pages/InstrumentView.js and 2 other locations - About 2 hrs to fix
react/src/pages/InstrumentMap.js on lines 573..577
react/src/pages/InstrumentView.js on lines 482..486

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

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 3 locations. Consider refactoring.
Open

                    case 'CcSequence':
                      return (
                          <StyledListItem className={classes.nested}>
                            <SequenceItem instrumentId={instrumentId} id={child.id} type={child.type} title={child.type} children={get(child,'children',[])} />
                          </StyledListItem>)
Severity: Major
Found in react/src/pages/InstrumentView.js and 2 other locations - About 2 hrs to fix
react/src/pages/InstrumentMap.js on lines 573..577
react/src/pages/InstrumentView.js on lines 417..421

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

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 3 locations. Consider refactoring.
Open

                  case 'CcSequence':
                    return (
                      <ListItem className={classes.nested}>
                        <SequenceItem instrumentId={instrumentId} id={child.id} type={child.type} title={child.type} children={get(child, 'children', [])} />
                      </ListItem>)
Severity: Major
Found in react/src/pages/InstrumentMap.js and 2 other locations - About 2 hrs to fix
react/src/pages/InstrumentView.js on lines 417..421
react/src/pages/InstrumentView.js on lines 482..486

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

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

Function ConfirmationModal has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const ConfirmationModal = (props) => {
  const { textToConfirm="", key="prefix", objectType="instrument", onConfirm=()=>{} } = props;
  const classes = useStyles();
  // getModalStyle is not a pure function, we roll the style only on the first render
  const [modalStyle] = React.useState(getModalStyle);
Severity: Major
Found in react/src/components/ConfirmationModal.js - About 2 hrs to fix
Severity
Category
Status
Source
Language