catarse/catarse.js

View on GitHub
legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx

Summary

Maintainability
D
2 days
Test Coverage

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

    oninit({attrs, state} : m.Vnode<UserInfoEditSettingsAttrs, UserInfoEditSettingsState>) {
        const hasErrorOn = attrs.hasErrorOn
        const getErrorsOn = attrs.getErrorsOn
        const user = attrs.user
        user.address = user.address || {
Severity: Major
Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 7 hrs to fix

    File user-info-edit-settings.tsx has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import m from 'mithril';
    import prop from 'mithril/stream';
    import _ from 'underscore';
    import { StreamType } from '../../../@types/reward-details-stream';
    import { UserDetails } from '../../../@types/user-details';
    Severity: Minor
    Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 3 hrs to fix

      Function hasError has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  hasError: (field : string) => {
                      switch(field) {
                          case 'address_zip_code': {
                              errors.addressZipCode(hasErrorOn(field))
                              break;
      Severity: Major
      Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 2 hrs to fix

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

            oninit({attrs, state} : m.Vnode<UserInfoEditSettingsAttrs, UserInfoEditSettingsState>) {
                const hasErrorOn = attrs.hasErrorOn
                const getErrorsOn = attrs.getErrorsOn
                const user = attrs.user
                user.address = user.address || {
        Severity: Minor
        Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - 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 addViewModel has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function addViewModel() {
        
                    const statesProp = prop<State[]>([])
        
                    const fieldsMap = {
        Severity: Minor
        Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 1 hr to fix

          Function WhenChangeNationality has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function WhenChangeNationality(user : UserDetails, states: prop<State[]>) : UserAddress {
              const defaultCountryID = 36 // Brasil
              const isInternational = Number(user.address.country_id) !== defaultCountryID
          
              if (!_.isEmpty(states()) && !isInternational) {
          Severity: Minor
          Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 1 hr to fix

            Avoid too many return statements within this function.
            Open

                                    return hasErrorOn('address_city')
            Severity: Major
            Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                      return hasErrorOn('phone_number')
              Severity: Major
              Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return hasErrorOn(field)
                Severity: Major
                Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                          return hasErrorOn('address_neighbourhood')
                  Severity: Major
                  Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                            return hasErrorOn('address_zip_code')
                    Severity: Major
                    Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - About 30 mins to fix

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

                      function WhenChangeNationality(user : UserDetails, states: prop<State[]>) : UserAddress {
                          const defaultCountryID = 36 // Brasil
                          const isInternational = Number(user.address.country_id) !== defaultCountryID
                      
                          if (!_.isEmpty(states()) && !isInternational) {
                      Severity: Minor
                      Found in legacy/src/c/projects/publish-by-steps/user-info-edit-settings.tsx - 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

                      There are no issues that match your filters.

                      Category
                      Status