CLOSER-Cohorts/archivist

View on GitHub

Showing 2,591 of 2,591 total issues

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

const TopicList = (props) => {
  const {topicId, datasetId, variableId} = props

  const dispatch = useDispatch()

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

Function AdminDatasetImportMappings has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminDatasetImportMappings = (props) => {
  const dispatch = useDispatch()
  const type = "Dataset"
  const hint = "You can import multiple T-V and DV mapping files. Only TXT files are accepted."
  const datasetId = get(props, "match.params.datasetId", "")
Severity: Minor
Found in react/src/pages/AdminDatasetImportMappings.js - About 1 hr to fix

Function AdminInstrumentImportMappings has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdminInstrumentImportMappings = (props) => {
  const dispatch = useDispatch()
  const type = "Instrument"
  const hint = "You can import multiple Q-V and T-Q mapping files. Only TXT files are accepted."
  const instrumentId = get(props, "match.params.instrumentId", "")
Severity: Minor
Found in react/src/pages/AdminInstrumentImportMappings.js - About 1 hr to fix

Function AdminInstrumentDatasetForm has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const [selectedDatasets, setSelectedDatasets] = React.useState([]);

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

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

  def import(options = {})
    Map.where(id: @object.maps.pluck(:id)).delete_all
    set_import_to_running
    @doc.each do |control_construct_scheme, q, dataset, v|
      log :input, "#{control_construct_scheme},#{q},#{dataset},#{v}"
Severity: Minor
Found in lib/importers/txt/mapper/mapping.rb - About 1 hr to fix

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

const responseDomainCodes = (state = {}, action) => {

  switch (action.type) {
    case 'LOAD_INSTRUMENT_RESPONSE_DOMAIN_CODES':
      return {...state, ...{[action.payload.instrumentId]: serializeArrayToObject(action.payload.responseDomainCodes)}}
Severity: Major
Found in react/src/reducers/index.js and 2 other locations - About 1 hr to fix
react/src/reducers/index.js on lines 257..265
react/src/reducers/index.js on lines 407..415

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

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

const categories = (state = {}, action) => {

  switch (action.type) {
    case 'LOAD_INSTRUMENT_CATEGORIES':
      return {...state, ...{[action.payload.instrumentId]: serializeArrayToObject(action.payload.categories)}}
Severity: Major
Found in react/src/reducers/index.js and 2 other locations - About 1 hr to fix
react/src/reducers/index.js on lines 257..265
react/src/reducers/index.js on lines 353..361

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

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

const validate = values => {
  const errors = {};
   if (!values.label) {
     errors.label = 'Required';
   }
Severity: Major
Found in react/src/components/ResponseDomainNumericForm.js and 1 other location - About 1 hr to fix
react/src/components/ResponseDomainDatetimeForm.js on lines 32..41

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

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

const validate = values => {
  const errors = {};
   if (!values.label) {
     errors.label = 'Required';
   }
Severity: Major
Found in react/src/components/ResponseDomainDatetimeForm.js and 1 other location - About 1 hr to fix
react/src/components/ResponseDomainNumericForm.js on lines 24..33

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

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

const variables = (state = {}, action) => {

  switch (action.type) {
    case 'LOAD_INSTRUMENT_VARIABLES':
      return {...state, ...{[action.payload.instrumentId]: serializeArrayToObject(action.payload.variables)}}
Severity: Major
Found in react/src/reducers/index.js and 2 other locations - About 1 hr to fix
react/src/reducers/index.js on lines 353..361
react/src/reducers/index.js on lines 407..415

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

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

    return (dispatch) => {
        return request.then(res => {
          dispatch(importMappingFetchSuccess(type, parentId, res.data));
        })
        .catch(err => {
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 304..311

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

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

    return (dispatch) => {
        return request.then(res => {
          dispatch(importMappingsFetchSuccess(id, type, res.data));
        })
        .catch(err => {
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 317..324

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

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 import has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def import(options = {})
    set_import_to_running
    vars = @object.variables.includes(:questions, :src_variables, :der_variables, :topic)
    begin
        @doc.each do |variable_dataset, v, source_dataset, s|
Severity: Minor
Found in lib/importers/txt/mapper/dv.rb - About 1 hr to fix

Method copy has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def copy(new_prefix, other_vals = {})
    new_i = self.dup
    new_i.prefix = new_prefix
    other_vals.select { |key, val| new_i[key] = val }

Severity: Minor
Found in app/models/instrument.rb - About 1 hr to fix

Function ObjectFinder has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ObjectFinder = (instrumentId) => {
  const sequences = useSelector(state => state.cc_sequences);
  const cc_sequences = get(sequences, instrumentId, {})
  const statements = useSelector(state => state.cc_statements);
  const cc_statements = get(statements, instrumentId, {})
Severity: Minor
Found in react/src/pages/InstrumentConstructBuild.js - About 1 hr to fix

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

      { title: `${item.label} Else`, expanded: expanded, conditionId: item.id, type: 'conditionFalse', children: fchildren.map(child => TreeNode(instrumentId, child.type, child.id, objectFinder)) },
Severity: Major
Found in react/src/pages/InstrumentConstructBuild.js and 1 other location - About 1 hr to fix
react/src/pages/InstrumentConstructBuild.js on lines 45..45

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

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

      { title: `${item.label} True`, expanded: expanded, conditionId: item.id, type: 'conditionTrue', children: children.map(child => TreeNode(instrumentId, child.type, child.id, objectFinder)) },
Severity: Major
Found in react/src/pages/InstrumentConstructBuild.js and 1 other location - About 1 hr to fix
react/src/pages/InstrumentConstructBuild.js on lines 46..46

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

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 resolved_topic_conflict is too high. [7/6]
Open

  def resolved_topic_conflict
    return if variable.nil? || source.nil? || variable.derived? || source.resolved_topic.nil? || variable.resolved_topic.nil?
    if source.resolved_topic != variable.resolved_topic
      errors.add(:topic, I18n.t('activerecord.errors.models.map.attributes.resolved_topic.variables_conflict', variable: variable, source: source, variable_topic: variable.resolved_topic, source_topic: source.resolved_topic))
    end
Severity: Minor
Found in app/models/map.rb by rubocop

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.

Cyclomatic complexity for << is too high. [7/6]
Open

  def <<(new_child)
    return if new_child.nil?
    case new_child
      when CcCondition
        @cc_conditions.reader << new_child
Severity: Minor
Found in app/models/children.rb by rubocop

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.

Cyclomatic complexity for import is too high. [7/6]
Open

  def import
    files = params[:files].nil? ? [] : params[:files]
    options = {}
    options[:prefix] = params[:instrument_prefix] if params.has_key? :instrument_prefix
    options[:agency] = params[:instrument_agency] if params.has_key? :instrument_agency

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.

Severity
Category
Status
Source
Language