CLOSER-Cohorts/archivist

View on GitHub

Showing 2,591 of 2,591 total issues

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

Method has too many lines. [33/30]
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!

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.

Cyclomatic complexity for question_grid_node is too high. [9/6]
Open

    def question_grid_node(node)
      question = ::QuestionGrid.new(
          {
              urn: node.at_xpath('./URN').content,            
              label: node.at_xpath('./QuestionGridName/String').content,
Severity: Minor
Found in lib/importers/xml/ddi/question.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. [9/6]
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 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.

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

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

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

              <ListItem button className={classes.nested}>
                <Link to={url(routes.admin.imports.all)}>
                  <ListItemText primary="DDI Imports" />
                </Link>
              </ListItem>
Severity: Major
Found in react/src/components/Dashboard.js and 4 other locations - About 2 hrs to fix
react/src/components/Dashboard.js on lines 177..181
react/src/components/Dashboard.js on lines 182..186
react/src/components/Dashboard.js on lines 187..191
react/src/components/Dashboard.js on lines 202..206

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

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

              <ListItem button className={classes.nested}>
                <Link to={url(routes.admin.instruments.exports)}>
                  <ListItemText primary="Instrument Exports" />
                </Link>
              </ListItem>
Severity: Major
Found in react/src/components/Dashboard.js and 4 other locations - About 2 hrs to fix
react/src/components/Dashboard.js on lines 177..181
react/src/components/Dashboard.js on lines 182..186
react/src/components/Dashboard.js on lines 187..191
react/src/components/Dashboard.js on lines 197..201

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

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

              <ListItem button className={classes.nested}>
                <Link to={url(routes.admin.datasets.all)}>
                  <ListItemText primary="Datasets" />
                </Link>
              </ListItem>
Severity: Major
Found in react/src/components/Dashboard.js and 4 other locations - About 2 hrs to fix
react/src/components/Dashboard.js on lines 177..181
react/src/components/Dashboard.js on lines 187..191
react/src/components/Dashboard.js on lines 197..201
react/src/components/Dashboard.js on lines 202..206

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

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

              <ListItem button className={classes.nested}>
                <Link to={url(routes.admin.users.all)}>
                  <ListItemText primary="Users" />
                </Link>
              </ListItem>
Severity: Major
Found in react/src/components/Dashboard.js and 4 other locations - About 2 hrs to fix
react/src/components/Dashboard.js on lines 177..181
react/src/components/Dashboard.js on lines 182..186
react/src/components/Dashboard.js on lines 197..201
react/src/components/Dashboard.js on lines 202..206

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

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

              <ListItem button className={classes.nested}>
                <Link to={url(routes.admin.instruments.all)}>
                  <ListItemText primary="Instruments" />
                </Link>
              </ListItem>
Severity: Major
Found in react/src/components/Dashboard.js and 4 other locations - About 2 hrs to fix
react/src/components/Dashboard.js on lines 182..186
react/src/components/Dashboard.js on lines 187..191
react/src/components/Dashboard.js on lines 197..201
react/src/components/Dashboard.js on lines 202..206

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

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 resolvedTopicIds = uniq(child_questions.map((question) => { return get(question, 'resolved_topic') }).filter((t) => { return t != null }).map((t) => { return t.id }))
Severity: Major
Found in react/src/pages/InstrumentMap.js and 1 other location - About 2 hrs to fix
react/src/pages/InstrumentMap.js on lines 113..113

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

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

  var topicIds = uniq(child_questions.map((question) => { return get(question, 'topic') }).filter((t) => { return t != null }).map((t) => { return t.id }))
Severity: Major
Found in react/src/pages/InstrumentMap.js and 1 other location - About 2 hrs to fix
react/src/pages/InstrumentMap.js on lines 114..114

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

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

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

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

Cyclomatic complexity for V3_2 is too high. [8/6]
Open

    def V3_2(qitem_id)
      @klass = ::QuestionItem

      super do |qitem, qi|
        build_response_domain = lambda do |rd|

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