bcgov/common-forms-toolkit

View on GitHub

Showing 88 of 559 total issues

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

  static get modifiers() {
    return {
      orderDescending(builder) {
        builder.orderBy('createdAt', 'desc');
      },
Severity: Minor
Found in app/src/forms/attestations/models/submission.js - About 1 hr to fix

    Function updateWatchVariables has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function updateWatchVariables(isAuthenticated = false) {
        watch.authenticated = isAuthenticated;
        watch.loginFn = keycloak.login;
        watch.login = keycloak.login;
        watch.createLoginUrl = keycloak.createLoginUrl;
    Severity: Minor
    Found in app/frontend/src/plugins/keycloak.js - About 1 hr to fix

      Function createSubmission has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async createSubmission(obj, user) {
          if (!obj) {
            throw Error(`${this._constants.TITLE} Submission cannot be created without data`);
          }
      
      
      Severity: Minor
      Found in app/src/forms/attestations/dataService.js - About 1 hr to fix

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

          async searchSubmissions(params) {
            if (params && params.tiny) {
              const submissions = await this._models.SubmissionSearchView.query()
                .modify('filterVersion', params.version)
                .modify('filterConfirmationId', params.confirmationId)
        Severity: Minor
        Found in app/src/forms/attestations/dataService.js - About 1 hr to fix

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

            constructor(slug, controller, models) {
              this._resourceAccess = `comfort-${slug}`;
              this._controller = controller;
              this._models = models;
              this._routes = require('express').Router();
          Severity: Minor
          Found in docs/sample/forms/myform/router.js - About 1 hr to fix

            Function modifiers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              static get modifiers() {
                return {
                  orderDescending(builder) {
                    builder.orderBy('createdAt', 'desc');
                  },
            Severity: Minor
            Found in app/src/forms/attestations/models/submission.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 modifiers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              static get modifiers() {
                return {
                  orderDescending(builder) {
                    builder.orderBy('createdAt', 'desc');
                  },
            Severity: Minor
            Found in app/src/forms/attestations/models/submission.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 modifiers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              static get modifiers () {
                return {
                  filterActive(query, value) {
                    if (value !== undefined) {
                      query.where('active', value);
            Severity: Minor
            Found in app/src/forms/common/models/base.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 modifiers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static get modifiers () {
                return {
                  filterActive(query, value) {
                    if (value !== undefined) {
                      query.where('active', value);
            Severity: Minor
            Found in app/src/forms/common/models/base.js - About 1 hr to fix

              Function searchSubmissions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async searchSubmissions(params) {
                  const tiny = data => {
                    if (!data || !Array.isArray(data) || !data.length) {
                      return [];
                    }
              Severity: Minor
              Found in docs/sample/forms/myform/dataService.js - About 1 hr to fix

                Function relationMappings has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  static get relationMappings() {
                    return {
                      survey: {
                        relation: Model.HasOneRelation,
                        modelClass: this.Survey,
                Severity: Minor
                Found in docs/sample/forms/myform/models/form.js - About 1 hr to fix

                  Function createSubmission has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async createSubmission(obj, user) {
                      if (!obj) {
                        throw Error(`${this._constants.TITLE} Submission cannot be created without data`);
                      }
                  
                  
                  Severity: Minor
                  Found in docs/sample/forms/myform/dataService.js - About 1 hr to fix

                    Function current has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async current(tiny) {
                        let form;
                        let version;
                    
                        if (tiny) {
                    Severity: Minor
                    Found in app/src/forms/attestations/dataService.js - About 1 hr to fix

                      Function current has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async current(tiny){
                          let form;
                          let version;
                      
                          if (tiny) {
                      Severity: Minor
                      Found in app/src/forms/common/dataService.js - About 1 hr to fix

                        Function searchSubmissions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async searchSubmissions(params) {
                            if (params && params.tiny) {
                              const submissions = await this._models.SubmissionSearchView.query()
                                .modify('filterVersion', params.version)
                                .modify('filterConfirmationId', params.confirmationId)
                        Severity: Minor
                        Found in app/src/forms/attestations/dataService.js - About 1 hr to fix

                          Function current has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async current(tiny) {
                              let form;
                              let version;
                          
                              if (tiny) {
                          Severity: Minor
                          Found in docs/sample/forms/myform/dataService.js - About 1 hr to fix

                            Function updateSubmission has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              async updateSubmission(submissionId, obj, user) {
                                // update: location, contacts, business
                                if (!obj) {
                                  throw Error(`${this._constants.TITLE} Submission cannot be updated without data`);
                                }
                            Severity: Minor
                            Found in app/src/forms/attestations/dataService.js - About 55 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

                            Avoid deeply nested control flow statements.
                            Open

                                          if (includeUserRoles) {
                                            ur.roles = await this._kcAdminClient.users.listClientRoleMappings({ id: ur.id, clientUniqueId: id });
                                          }
                            Severity: Major
                            Found in app/src/components/keycloakAdminService.js - About 45 mins to fix

                              Function assertOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function assertOptions(options) {
                                const { config, init, onReady, onInitError } = options;
                                if (typeof config !== 'string' && !_isObject(config)) {
                                  return { hasError: true, error: `'config' option must be a string or an object. Found: '${config}'` };
                                }
                              Severity: Minor
                              Found in app/frontend/src/plugins/keycloak.js - About 35 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

                              Function hasResourceRoles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  hasResourceRoles: (_state, getters) => (resource, roles) => {
                                    if (!getters.authenticated) return false;
                                    if (!roles.length) return true; // No roles to check against
                              
                                    if (getters.resourceAccess && getters.resourceAccess[resource]) {
                              Severity: Minor
                              Found in app/frontend/src/store/modules/auth.js - About 35 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

                              Severity
                              Category
                              Status
                              Source
                              Language