CLOSER-Cohorts/archivist

View on GitHub

Showing 219 of 2,583 total issues

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

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

Function ResetPassword has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function ResetPassword(props) {
  const classes = useStyles();

  const reset_password_token = get(props, "match.params.reset_password_token", "")
  const passwordField = useFormField();
Severity: Major
Found in react/src/pages/ResetPassword.js - About 2 hrs to fix

Function AdminDatasetForm has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const AdminDatasetForm = (props) => {
  const {} = props;

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

Function AdminImportInstrumentForm has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const AdminImportInstrumentForm = (props) => {
  const {} = props;

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

Class Instrument has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Instrument < DdiExporterBase
    # Creates the XML document for exporting to as
    # a DDIInstance
    def initialize
      @doc = Nokogiri::XML '<ddi:DDIInstance></ddi:DDIInstance>'
Severity: Minor
Found in lib/exporters/xml/ddi/instrument.rb - About 2 hrs to fix

Function ForgottenPassword has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function ForgottenPassword() {
  const classes = useStyles();

  const emailField = useFormField();

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

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

class Instrument < ApplicationRecord
  # This model is exportable as DDI
  include Exportable

  # This model can be tracked using an Identifier
Severity: Minor
Found in app/models/instrument.rb - About 2 hrs to fix

Function AdminDatasets has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminDatasets = () => {

  const dispatch = useDispatch()

  const deleteDataset = (datasetId) => {
Severity: Major
Found in react/src/pages/AdminDatasets.js - About 2 hrs to fix

Method update_cols has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def update_cols(cols)
      if cols.to_a.empty?
        self.rds_qs.delete_all
      else
        cols.sort_by! { |x| x[:order] }
Severity: Minor
Found in lib/question.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 add_variables has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def add_variables
    variable_names = params[:variable_names].is_a?(Array) ? params[:variable_names] : [params[:variable_names]]

    variables = @object.instrument.variables.where(name: variable_names)
    variables.to_a.compact!
Severity: Minor
Found in app/controllers/cc_questions_controller.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 QuestionItemForm.js has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { useEffect } from 'react';
import { get, isNil } from "lodash";
import { Form } from 'react-final-form';
import { useDispatch, useSelector } from 'react-redux'
import { QuestionItems, ResponseDomainNumerics, ResponseDomainTexts, ResponseDomainDatetimes, ResponseDomainCodes } from '../actions'
Severity: Minor
Found in react/src/components/QuestionItemForm.js - About 2 hrs to fix

Function InstrumentConstructBuild has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InstrumentConstructBuild = (props) => {

  const classes = useStyles();

  const dispatch = useDispatch()
Severity: Major
Found in react/src/pages/InstrumentConstructBuild.js - About 2 hrs to fix

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

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

Method question_grid_node has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def question_grid_node(node)
      question = ::QuestionGrid.new(
          {
              urn: node.at_xpath('./URN').content,            
              label: node.at_xpath('./QuestionGridName/String').content,
Severity: Major
Found in lib/importers/xml/ddi/question.rb - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

    if(this.props.monthData && this.props.yearData && this.props.projects && this.props.clients){

      const revenue_data = [];
      let revenue_forecast = 0;

Severity: Critical
Found in react/src/components/Home/index.js - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

    if (get(variable.topic, 'id') !== 0 && (!isEmpty(variable.topic) || !isEmpty(variable.sources_topic)) ){
      sourceOptions = sourceOptions.filter(opt => {
        return (
          get(opt.topic, 'id') == get(variable.topic, 'id') ||
          get(opt, 'topic') == get(variable.topic, 'name') ||
Severity: Critical
Found in react/src/pages/DatasetView.js - About 2 hrs to fix

Function QuestionItemListItem has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

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

Function ConditionChildren has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in react/src/pages/InstrumentView.js - About 1 hr to fix

Function TopicList has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TopicList = (props) => {
  const dispatch = useDispatch()
  const {topicId, instrumentId, ccQuestionId=undefined} = props
  const { handleChange=(event, value, reason) => {
    dispatch(CcQuestions.topic.set(instrumentId, ccQuestionId, (reason === 'clear') ? null : value.id));
Severity: Minor
Found in react/src/pages/InstrumentMap.js - About 1 hr to fix

Method process has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def process
      ActiveRecord::Base.transaction do
        parsed_fragment = parse
        raise ActiveRecord::Rollback unless valid?
        create_categories(parsed_fragment[:categories])
Severity: Minor
Found in lib/importers/xml/ddi/fragment_instance.rb - 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

Severity
Category
Status
Source
Language