CLOSER-Cohorts/archivist

View on GitHub

Showing 2,591 of 2,591 total issues

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

              }else if(params.subtype === 'response_domains'){
                  crumbs.push(
                      {
                        text: 'Response Domains',
                        link: url(routes.instruments.instrument.build.responseDomains.all, { instrument_id: instrumentId })
Severity: Major
Found in react/src/components/BreadcrumbBar.js and 4 other locations - About 1 hr to fix
react/src/components/BreadcrumbBar.js on lines 103..138
react/src/components/BreadcrumbBar.js on lines 110..138
react/src/components/BreadcrumbBar.js on lines 117..138
react/src/components/BreadcrumbBar.js on lines 131..138

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

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

              }else if(params.subtype === 'constructs'){
                  crumbs.push(
                      {
                        text: 'Constructs',
                        link: url(routes.instruments.instrument.build.constructs.show, { instrument_id: instrumentId })
Severity: Major
Found in react/src/components/BreadcrumbBar.js and 4 other locations - About 1 hr to fix
react/src/components/BreadcrumbBar.js on lines 103..138
react/src/components/BreadcrumbBar.js on lines 110..138
react/src/components/BreadcrumbBar.js on lines 117..138
react/src/components/BreadcrumbBar.js on lines 124..138

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

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

              if(params.subtype === 'question_items'){
                  crumbs.push(
                      {
                        text: 'Question Items',
                        link: url(routes.instruments.instrument.build.questionItems.all, { instrument_id: instrumentId })
Severity: Major
Found in react/src/components/BreadcrumbBar.js and 4 other locations - About 1 hr to fix
react/src/components/BreadcrumbBar.js on lines 110..138
react/src/components/BreadcrumbBar.js on lines 117..138
react/src/components/BreadcrumbBar.js on lines 124..138
react/src/components/BreadcrumbBar.js on lines 131..138

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

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

              }else if(params.subtype === 'code_lists'){
                  crumbs.push(
                      {
                        text: 'CodeLists',
                        link: url(routes.instruments.instrument.build.codeLists.all, { instrument_id: instrumentId })
Severity: Major
Found in react/src/components/BreadcrumbBar.js and 4 other locations - About 1 hr to fix
react/src/components/BreadcrumbBar.js on lines 103..138
react/src/components/BreadcrumbBar.js on lines 110..138
react/src/components/BreadcrumbBar.js on lines 124..138
react/src/components/BreadcrumbBar.js on lines 131..138

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

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

              }else if(params.subtype === 'question_grids'){
                  crumbs.push(
                      {
                        text: 'Question Grids',
                        link: url(routes.instruments.instrument.build.questionGrids.all, { instrument_id: instrumentId })
Severity: Major
Found in react/src/components/BreadcrumbBar.js and 4 other locations - About 1 hr to fix
react/src/components/BreadcrumbBar.js on lines 103..138
react/src/components/BreadcrumbBar.js on lines 117..138
react/src/components/BreadcrumbBar.js on lines 124..138
react/src/components/BreadcrumbBar.js on lines 131..138

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

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

const importMappingFetchSuccess = (type, parentId, importMapping) => {
  const reducerType = (type === 'instruments' ) ? 'LOAD_INSTRUMENT_IMPORT_MAPPING' : 'LOAD_DATASET_IMPORT_MAPPING'
  return {
    type: reducerType,
    payload: {
Severity: Major
Found in react/src/actions/index.js and 1 other location - About 1 hr to fix
react/src/actions/index.js on lines 1885..1894

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

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

    case 'SAVING':
      key = action.payload.type + ':' + action.payload.id
      return {...state, ...{[key]: {saving: true}}}
Severity: Major
Found in react/src/reducers/index.js and 1 other location - About 1 hr to fix
react/src/reducers/index.js on lines 449..451

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

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

    case 'SAVED':
      key = action.payload.type + ':' + action.payload.id
      return {...state, ...{[key]: {saved: true}}}
Severity: Major
Found in react/src/reducers/index.js and 1 other location - About 1 hr to fix
react/src/reducers/index.js on lines 446..448

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

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

        {instrument && instrument.signed_off && (
          <div>
            <Alert severity="error">
              <AlertTitle>Read Only</AlertTitle>
              Instrument has been signed off so you can only view this as read-only.
Severity: Major
Found in react/src/pages/InstrumentBuild.js and 1 other location - About 1 hr to fix
react/src/components/BuildContainer.js on lines 135..142

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

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

            {instrument && instrument.signed_off && (
              <div>
                <Alert severity="error">
                  <AlertTitle>Read Only</AlertTitle>
                  Instrument has been signed off so you can only view this as read-only.
Severity: Major
Found in react/src/components/BuildContainer.js and 1 other location - About 1 hr to fix
react/src/pages/InstrumentBuild.js on lines 73..80

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

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

const importMappingsFetchSuccess = (id, type, imports) => {
  const reducerType = (type === 'instruments' ) ? 'LOAD_INSTRUMENT_IMPORT_MAPPINGS' : 'LOAD_DATASET_IMPORT_MAPPINGS'
  return {
    type: reducerType,
    payload: {
Severity: Major
Found in react/src/actions/index.js and 1 other location - About 1 hr to fix
react/src/actions/index.js on lines 1896..1905

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

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

Method clear_cached_stats has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def clear_cached_stats
    self.class.reflections.keys.each do |key|
      if self.class.reflections[key].is_a? ActiveRecord::Reflection::BelongsToReflection
        unless self.send(key).nil?
          begin
Severity: Minor
Found in app/models/application_record.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

Method update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    with_unconfirmed_confirmable do
      if @confirmable.has_no_password?
        @confirmable.attempt_set_password(params[:user])
        if @confirmable.valid? and @confirmable.password_match?
Severity: Minor
Found in app/controllers/users/confirmations_controller.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

Method all has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def all
    instruments = Rails.cache.fetch('instruments.json&#{auth_token}', version: Instrument.maximum(:updated_at).to_i) do
      connection = ActiveRecord::Base.connection
      sql = %|
              SELECT instruments.id, instruments.agency, instruments.version, instruments.prefix, instruments.label, instruments.slug, instruments.study, instruments.signed_off, COUNT(DISTINCT(control_constructs.id)) as ccs, COUNT(DISTINCT(qv_mappings.id)) as qvs
Severity: Minor
Found in app/services/instruments/serializer.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

Method shim_construct_type has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def shim_construct_type(p)
    # Ensure that if the parent_type is a valid ParentalContstruct class name
    # or that it can be matched to one.
    parental_classes = %w(CcCondition CcLoop CcQuestion CcSequence CcStatement)
    unless p[:parent_type].nil? || parental_classes.include?(p[:parent_type])
Severity: Minor
Found in app/controllers/construct_controller.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

Function actions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const actions = (row) => {
    return (
      <>
        <ButtonGroup variant="outlined">
          <Button>
Severity: Minor
Found in react/src/pages/AdminInstrumentExports.js - About 1 hr to fix

Function HumanizeObjectType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const HumanizeObjectType = (type) => {
   switch (type){
      case 'statement':
      case 'CcStatement':
         return 'Statement'
Severity: Minor
Found in react/src/support/HumanizeObjectType.js - About 1 hr to fix

Method import has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def import(options = {})
      options.symbolize_keys!

      if options.has_key? :import_id
        @import = Import.find_by_id(options[:import_id])
Severity: Minor
Found in lib/importers/xml/ddi/instrument.rb - About 1 hr to fix

Method all has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def all
    instruments = Rails.cache.fetch('instruments.json&#{auth_token}', version: Instrument.maximum(:updated_at).to_i) do
      connection = ActiveRecord::Base.connection
      sql = %|
              SELECT instruments.id, instruments.agency, instruments.version, instruments.prefix, instruments.label, instruments.slug, instruments.study, instruments.signed_off, COUNT(DISTINCT(control_constructs.id)) as ccs, COUNT(DISTINCT(qv_mappings.id)) as qvs
Severity: Minor
Found in app/services/instruments/serializer.rb - About 1 hr to fix

Method V3_2 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def V3_2(seq_id)
      if seq_id.is_a? ::CcSequence
        cc = seq_id
      else
        cc = ::CcSequence.find seq_id
Severity: Minor
Found in lib/exporters/xml/ddi/cc_sequence.rb - About 1 hr to fix
Severity
Category
Status
Source
Language