catarse/catarse.js

View on GitHub
legacy/src/c/edit-reward-card.js

Summary

Maintainability
F
4 days
Test Coverage

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

    oninit: function(vnode) {
        const project = projectVM.getCurrentProject(),
            reward = vnode.attrs.reward(),
            imageFileToUpload = prop(null),
            minimumValue = projectVM.isSubscription(project) ? 5 : 10,
Severity: Major
Found in legacy/src/c/edit-reward-card.js - About 1 day to fix

    File edit-reward-card.js has 486 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import m from 'mithril';
    import prop from 'mithril/stream';
    import moment from 'moment';
    import _ from 'underscore';
    import h from '../h';
    Severity: Minor
    Found in legacy/src/c/edit-reward-card.js - About 7 hrs to fix

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

          view: function({
              state,
              attrs
          }) {
              const newFee = {
      Severity: Minor
      Found in legacy/src/c/edit-reward-card.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

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

          oninit: function(vnode) {
              const project = projectVM.getCurrentProject(),
                  reward = vnode.attrs.reward(),
                  imageFileToUpload = prop(null),
                  minimumValue = projectVM.isSubscription(project) ? 5 : 10,
      Severity: Minor
      Found in legacy/src/c/edit-reward-card.js - About 5 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

      Function saveReward has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  saveReward = () => {
                      isSavingReward(true);
                      validate();
                      if (vnode.attrs.error()) {
                          isSavingReward(false);
      Severity: Major
      Found in legacy/src/c/edit-reward-card.js - About 3 hrs to fix

        Function validate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    validate = () => {
                        vnode.attrs.error(false);
                        vnode.attrs.errors('Erro ao salvar informações. Confira os dados informados.');
                        descriptionError(false);
                        minimumValueError(false);
        Severity: Minor
        Found in legacy/src/c/edit-reward-card.js - About 1 hr to fix

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

                              rewardVM.updateReward(vnode.attrs.project_id, reward.id(), data).then(() => {
                                  vnode.attrs.showSuccess(true);
                                  reward.edit.toggle();
          
                                  vnode.attrs.uploadImage(reward, imageFileToUpload, vnode.attrs.project_id, reward.id())
          Severity: Major
          Found in legacy/src/c/edit-reward-card.js and 1 other location - About 1 hr to fix
          legacy/src/c/edit-reward-card.js on lines 141..168

          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

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

                              rewardVM.createReward(vnode.attrs.project_id, data).then((r) => {
                                      vnode.attrs.showSuccess(true);
                                      reward.newReward = false;
                                      // save id so we can update without reloading the page
                                      reward.id(r.reward_id);
          Severity: Major
          Found in legacy/src/c/edit-reward-card.js and 1 other location - About 1 hr to fix
          legacy/src/c/edit-reward-card.js on lines 174..197

          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

                          if (((reward.shipping_options() === 'national' || reward.shipping_options() === 'international') && !_.contains(destinations, 'others'))) {
                              fees().push({
                                  id: prop(null),
                                  value: prop(0),
                                  destination: prop('others')
          Severity: Minor
          Found in legacy/src/c/edit-reward-card.js and 1 other location - About 35 mins to fix
          legacy/src/c/edit-reward-card.js on lines 212..218

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

          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

                          } else if (reward.shipping_options() === 'international' && !_.contains(destinations, 'international')) {
                              fees().push({
                                  id: prop(null),
                                  value: prop(0),
                                  destination: prop('international')
          Severity: Minor
          Found in legacy/src/c/edit-reward-card.js and 1 other location - About 35 mins to fix
          legacy/src/c/edit-reward-card.js on lines 203..209

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

          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