catarse/catarse.js

View on GitHub
legacy/src/root/surveys-show.js

Summary

Maintainability
F
3 days
Test Coverage

Function view has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    view: function({state}) {
        const user = state.user(),
            survey = state.survey(),
            countryName = state.countryName,
            stateName = state.stateName,
Severity: Minor
Found in legacy/src/root/surveys-show.js - About 6 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 surveys-show.js has 428 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import m from 'mithril';
import prop from 'mithril/stream';
import _ from 'underscore';
import { catarse } from '../api';
import models from '../models';
Severity: Minor
Found in legacy/src/root/surveys-show.js - About 6 hrs to fix

    Function oninit has 131 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        oninit: function(vnode) {
            const {
                    survey_id
                } = vnode.attrs,
                contributionId = m.route.param('contribution_id'),
    Severity: Major
    Found in legacy/src/root/surveys-show.js - About 5 hrs to fix

      Function loadSurvey has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              const loadSurvey = () => {
                  surveyLoader().load().then((data) => {
                      survey(_.first(data));
                      finished(!_.isEmpty(survey().finished_at));
                      answeredAt(survey().survey_answered_at);
      Severity: Minor
      Found in legacy/src/root/surveys-show.js - About 1 hr to fix

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

                    sendAnswer = () => {
                        const data = {};
                        _.extend(data, {
                            survey_address_answers_attributes: {
                                addresses_attributes: addVM().getFields()
        Severity: Minor
        Found in legacy/src/root/surveys-show.js - About 1 hr to fix

          Function oninit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              oninit: function(vnode) {
                  const {
                          survey_id
                      } = vnode.attrs,
                      contributionId = m.route.param('contribution_id'),
          Severity: Minor
          Found in legacy/src/root/surveys-show.js - About 25 mins 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

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

                  vnode.state = {
                      projectVM,
                      loadSurvey,
                      countryName,
                      stateName,
          Severity: Major
          Found in legacy/src/root/surveys-show.js and 1 other location - About 3 hrs to fix
          legacy/src/c/user-about-edit.js on lines 200..219

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

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

                                      m(surveyPreview, {
                                          confirmAddress: survey.confirm_address,
                                          countryName: countryName(),
                                          stateName: stateName(),
                                          fields: state.addVM().getFields(),
          Severity: Major
          Found in legacy/src/root/surveys-show.js and 2 other locations - About 1 hr to fix
          legacy/src/root/surveys-show.js on lines 216..223
          legacy/src/root/surveys-show.js on lines 337..344

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

                                                          m(surveyPreview, {
                                                              confirmAddress: survey.confirm_address,
                                                              countryName: countryName(),
                                                              stateName: stateName(),
                                                              fields: state.addVM().getFields(),
          Severity: Major
          Found in legacy/src/root/surveys-show.js and 2 other locations - About 1 hr to fix
          legacy/src/root/surveys-show.js on lines 216..223
          legacy/src/root/surveys-show.js on lines 244..251

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

                                  m(surveyPreview, {
                                      confirmAddress: survey.confirm_address,
                                      countryName: countryName(),
                                      stateName: stateName(),
                                      fields: state.addVM().getFields(),
          Severity: Major
          Found in legacy/src/root/surveys-show.js and 2 other locations - About 1 hr to fix
          legacy/src/root/surveys-show.js on lines 244..251
          legacy/src/root/surveys-show.js on lines 337..344

          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

                          _.map(surveyData.multiple_choice_questions, (question) => {
                              multipleChoiceQuestions().push({
                                  question,
                                  value: prop(question.survey_question_choice_id)
                              });
          Severity: Major
          Found in legacy/src/root/surveys-show.js and 1 other location - About 1 hr to fix
          legacy/src/root/surveys-show.js on lines 122..127

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

          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

                          _.map(surveyData.open_questions, (question) => {
                              openQuestions().push({
                                  question,
                                  value: prop(question.answer)
                              });
          Severity: Major
          Found in legacy/src/root/surveys-show.js and 1 other location - About 1 hr to fix
          legacy/src/root/surveys-show.js on lines 128..133

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

          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

                      surveyLoader = () => {
                          vm.contribution_id(contributionId);
                          return catarse.loaderWithToken(models.survey.getPageOptions(vm.parameters()));
                      },
          Severity: Minor
          Found in legacy/src/root/surveys-show.js and 1 other location - About 30 mins to fix
          legacy/src/vms/reward-vm.js on lines 24..28

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

          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

          There are no issues that match your filters.

          Category
          Status