CLOSER-Cohorts/archivist

View on GitHub

Showing 219 of 2,583 total issues

Function CcLoopForm has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const CcLoopForm = (props) => {
  const {ccLoop, instrumentId, onChange, path, onDelete, onCreate} = props;

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

Function ResponseDomainTextForm has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const codeLists = useSelector(state => get(state.codeLists, instrumentId, {}));

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

Function ResponseDomainNumericForm has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const codeLists = useSelector(state => get(state.codeLists, instrumentId, {}));

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

Function NewConstructQuestion has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NewConstructQuestion = (props) => {
  const { object, onNodeSelect, onDelete, path, onChange } = props;

  const classes = useStyles();

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

Function LoopItem has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LoopItem = (props) => {
  const {type, id, instrumentId, title} = props
  const classes = useStyles();
  const [open, setOpen] = React.useState(true);

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

Function formFields has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const formFields = (item) => {
  return [
    {
      size: 12,
      field: (
Severity: Major
Found in react/src/components/UserForm.js - About 3 hrs to fix

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

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

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

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

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

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

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

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

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

const SequenceItem = (props) => {
  const { instrumentId } = props;
  var {title} = props;
  const classes = useStyles();
  const [open, setOpen] = React.useState(true);
Severity: Major
Found in react/src/pages/InstrumentMap.js - About 2 hrs to fix

Method build_instrument has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def self.build_instrument(doc, options= {}, instrument_importer=nil)
      save = defined?(options[:save]) ? true : options[:save]
      duplicate = defined?(options[:duplicate]) ? :do_nothing : options[:duplicate]

      i = ::Instrument.new
Severity: Minor
Found in lib/importers/xml/ddi/instrument.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

Severity
Category
Status
Source
Language