catarse/catarse.js

View on GitHub
legacy/src/c/user-about-edit.js

Summary

Maintainability
F
4 days
Test Coverage

File user-about-edit.js has 531 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import m from 'mithril';
import prop from 'mithril/stream';
import _ from 'underscore';
import h from '../h';
import userVM from '../vms/user-vm';
Severity: Major
Found in legacy/src/c/user-about-edit.js - About 1 day to fix

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

        oninit: function(vnode) {
            let parsedErrors = userAboutVM.mapRailsErrors(railsErrorsVM.railsErrors());
            let deleteUser;
            const user = vnode.attrs.user || {},
                fields = {
    Severity: Major
    Found in legacy/src/c/user-about-edit.js - About 7 hrs to fix

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

          view: function({state, attrs}) {
              const user = attrs.user || {},
                  fields = state.fields;
      
              return m('#about-tab.content', [
      Severity: Minor
      Found in legacy/src/c/user-about-edit.js - About 3 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 21 (exceeds 5 allowed). Consider refactoring.
      Open

          oninit: function(vnode) {
              let parsedErrors = userAboutVM.mapRailsErrors(railsErrorsVM.railsErrors());
              let deleteUser;
              const user = vnode.attrs.user || {},
                  fields = {
      Severity: Minor
      Found in legacy/src/c/user-about-edit.js - About 2 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 updateUser has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  updateUser = () => {
                      const userData = {
                          current_password: fields.current_password(),
                          password: fields.password(),
                          email: fields.email(),
      Severity: Minor
      Found in legacy/src/c/user-about-edit.js - About 1 hr to fix

        Function uploadImage has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    uploadImage = () => {
                        const userUploadedImageEl = window.document.getElementById('user_uploaded_image'),
                            userCoverImageEl = window.document.getElementById('user_cover_image'),
                            formData = new FormData();
        
        
        Severity: Minor
        Found in legacy/src/c/user-about-edit.js - About 1 hr to fix

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

                  vnode.state = {
                      removeLinks,
                      removeLink,
                      addLink,
                      fields,
          Severity: Major
          Found in legacy/src/c/user-about-edit.js and 1 other location - About 3 hrs to fix
          legacy/src/root/surveys-show.js on lines 137..156

          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

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

                                                          m('input.password.optional.w-input.text-field.w-input.text-field.positive[id=\'user_password\'][name=\'user[password]\'][type=\'password\']', {
                                                              class: state.passwordHasError() ? 'error' : '',
                                                              value: fields.password(),
                                                              onfocus: () => state.passwordHasError(false),
                                                              onblur: state.validatePassword,
          Severity: Major
          Found in legacy/src/c/user-about-edit.js and 1 other location - About 2 hrs to fix
          legacy/src/c/user-about-edit.js on lines 301..307

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

          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

                                                      m('input.string.required.w-input.text-field.w-input.text-field.positive[id=\'new_email_confirmation\'][name=\'user[email]\'][type=\'text\']', {
                                                          class: state.emailHasError() ? 'error' : '',
                                                          value: fields.email_confirmation(),
                                                          onfocus: () => state.emailHasError(false),
                                                          onblur: state.validateEmailConfirmation,
          Severity: Major
          Found in legacy/src/c/user-about-edit.js and 1 other location - About 2 hrs to fix
          legacy/src/c/user-about-edit.js on lines 499..505

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

          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

                                              m('.w-row.u-marginbottom-10', [
                                                  m('.w-col.w-col-5.w-sub-col', [
                                                      m('label.field-label.fontweight-semibold',
                                                          '  Perfil do twitter'
                                                      ),
          Severity: Major
          Found in legacy/src/c/user-about-edit.js and 1 other location - About 1 hr to fix
          legacy/src/c/user-about-edit.js on lines 398..414

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

          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

                                              m('.w-row.u-marginbottom-10', [
                                                  m('.w-col.w-col-5.w-sub-col', [
                                                      m('label.field-label.fontweight-semibold',
                                                          '  Perfil do facebook'
                                                      ),
          Severity: Major
          Found in legacy/src/c/user-about-edit.js and 1 other location - About 1 hr to fix
          legacy/src/c/user-about-edit.js on lines 415..431

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

          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 m.request({
                              method: 'PUT',
                              url: `/users/${user.id}.json`,
                              data: {
                                  user: userData
          Severity: Major
          Found in legacy/src/c/user-about-edit.js and 1 other location - About 1 hr to fix
          legacy/src/vms/common-payment-vm.js on lines 39..50

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

          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