CLOSER-Cohorts/archivist

View on GitHub

Showing 2,591 of 2,591 total issues

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

      const request = axios.post(api_host + '/instruments/' + instrumentId + '/cc_questions/' + ccQuestionId + '/remove_variable.json',
      {
        "variable_id": variableId,
        "x": x,
        "y": y
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 1180..1188

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

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

Consider simplifying this complex logical expression.
Open

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

Method add_variables has 33 lines of code (exceeds 25 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 1 hr to fix

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

const validate = (values, status) => {

  const errors = {};

  if (!values.files || isEmpty(values.files)) {
Severity: Major
Found in react/src/components/AdminDatasetForm.js and 1 other location - About 1 hr to fix
react/src/components/AdminImportInstrumentForm.js on lines 28..37

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

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, status) => {

  const errors = {};

  if (!values.files || isEmpty(values.files)) {
Severity: Major
Found in react/src/components/AdminImportInstrumentForm.js and 1 other location - About 1 hr to fix
react/src/components/AdminDatasetForm.js on lines 28..37

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

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} Else`, expanded: false, conditionId: item.id, type: 'conditionFalse', children: fchildren.map(child => TreeNodeFormatter(instrumentId, child)) },
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 63..63

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

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: false, conditionId: item.id, type: 'conditionTrue', children: tchildren.map(child => TreeNodeFormatter(instrumentId, child)) },
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 64..64

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

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

  render() {
    return (

      <main>

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

Method construct_children has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def construct_children(branch = nil)
    query_children = lambda do |query_branch, cc|
      if query_branch.nil?
        return cc.children.map { |c| {id: c.id, type: c.class.name } }
      else
Severity: Minor
Found in app/models/parental_construct.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 ObjectCheckForInitialValues has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const ObjectCheckForInitialValues = (initialValues, values) => {
    // For every field initially provided, we check whether it value has been removed
    // and set it explicitly to an empty string
    if (!initialValues) return values;
    const initialValuesWithEmptyFields = Object.keys(initialValues).reduce(
Severity: Minor
Found in react/src/support/ObjectCheckForInitialValues.js - 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 Tree has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const Tree = (props) => {
  const { topSequence, instrumentId, dispatch, onNodeSelect } = props
  const objectFinder = ObjectFinder(instrumentId);
  const [treeData, setTreeData] = useState([TreeNode(instrumentId, 'CcSequence', topSequence.id, objectFinder, true)]);
  const [selectedNode, setSelectedNode] = useState({});
Severity: Minor
Found in react/src/pages/InstrumentConstructBuild.js - 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 VariableList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const VariableList = (props) => {
  const {variables, instrumentId, ccQuestionId, x, y, topicId, label='Variables'} = props

  const dispatch = useDispatch()

Severity: Minor
Found in react/src/pages/InstrumentMap.js - 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

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

  useEffect(() => {
    Promise.all([
      dispatch(UserGroup.all())
    ]).then(() => {
      setDataLoaded(true)
Severity: Major
Found in react/src/components/AdminUserForm.js and 1 other location - About 1 hr to fix
react/src/components/UserForm.js on lines 152..159

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

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

  useEffect(() => {
    Promise.all([
      dispatch(UserGroup.all())
    ]).then(() => {
      setDataLoaded(true)
Severity: Major
Found in react/src/components/UserForm.js and 1 other location - About 1 hr to fix
react/src/components/AdminUserForm.js on lines 127..134

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

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

                          <p>We don't think you'll meet your annual goal of {this.props.yearData.yearly_target_formatted} as you're
                          averaging {this.props.yearData.monthly_average_revenue_formatted}/month. To get back on track,
                          you need to be earning {this.props.yearData.amount_required_each_month_to_now_hit_target_formatted}/month going forward.</p>
Severity: Major
Found in react/src/components/Home/index.js and 1 other location - About 1 hr to fix
react/src/components/Home/index.js on lines 422..424

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

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

                        <p>You’ve only worked {this.props.yearData.total_productivity_percentage}% of the days available to work so far this year
                        ({this.props.yearData.number_of_days_worked} out of {this.props.yearData.total_workable_days_to_date}). We recommend finding some new
                        clients to help fill this gap in the coming months.</p>
Severity: Major
Found in react/src/components/Home/index.js and 1 other location - About 1 hr to fix
react/src/components/Home/index.js on lines 339..341

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

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

function registerValidSW(swUrl, config) {
  navigator.serviceWorker
    .register(swUrl)
    .then(registration => {
      registration.onupdatefound = () => {
Severity: Minor
Found in react/src/serviceWorker.js - About 1 hr to fix

Function VariableTableRow has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const VariableTableRow = (props) => {
    const { row } = props;

    const status = ObjectStatus(row.id, 'DatasetVariable')

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

Function ReadOnlyVariableTableRow has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const ReadOnlyVariableTableRow = (props) => {
    const { row } = props;

    const status = ObjectStatus(row.id, 'DatasetVariable')

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

Method XML_node has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def XML_node(node)
      codes_to_add = []
      node.xpath('./Code').each_with_index do |code, i|
        begin
          co = ::Code.new ({
Severity: Minor
Found in lib/importers/xml/ddi/code_list.rb - About 1 hr to fix
Severity
Category
Status
Source
Language