bcgov/common-forms-toolkit

View on GitHub

Showing 88 of 559 total issues

Function init has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function init(config, watch, options) {
  const ctor = sanitizeConfig(config);
  const keycloak = Keycloak(ctor);

  watch.$once('ready', function (cb) {
Severity: Major
Found in app/frontend/src/plugins/keycloak.js - About 2 hrs to fix

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

      static get relationMappings() {
        return {
          attestation: {
            relation: Model.HasOneRelation,
            modelClass: this.Attestation,
    Severity: Major
    Found in app/src/forms/attestations/models/submission.js - About 2 hrs to fix

      Function up has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.up = function(knex) {
        return Promise.resolve()
          .then(() => knex.schema.createTable(`${PREFIX}_form`, table => {
            table.uuid('formId').references('formId').inTable('form').notNullable().primary();
            table.string('description');
      Severity: Major
      Found in docs/sample/db/migrations/20200626145729_myform-common.js - About 2 hrs to fix

        File minesOperatorScreeningForm.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import moment from 'moment';
        
        import commonFormService from '@/services/commonFormService';
        import { FormNames } from '@/utils/constants';
        import { SampleData, RandomCities } from './sampleData.js';

          Function install has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            install: function (Vue, params = {}) {
              if (installed) return;
              installed = true;
          
              const defaultParams = {
          Severity: Major
          Found in app/frontend/src/plugins/keycloak.js - About 2 hrs to fix

            File agriSeafoodOpScreeningForm.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import moment from 'moment';
            
            import commonFormService from '@/services/commonFormService';
            import { FormNames } from '@/utils/constants';
            import { SampleData, RandomCities } from './sampleData.js';

              File farmOpScreeningForm.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import moment from 'moment';
              
              import commonFormService from '@/services/commonFormService';
              import { FormNames } from '@/utils/constants';
              import { SampleData, RandomCities } from './sampleData.js';
              Severity: Minor
              Found in app/frontend/src/store/modules/farmopscreening/farmOpScreeningForm.js - About 2 hrs to fix

                File forestrySectorOpScreeningForm.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import moment from 'moment';
                
                import commonFormService from '@/services/commonFormService';
                import { FormNames } from '@/utils/constants';
                import { SampleData, RandomCities } from './sampleData.js';

                  Function getClient has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                    async getClient(id, includeRoles = false, includeUsers = false, includeUserRoles = false) {
                      try {
                        // TEMP: refresh loop was DOSing SSO
                        await this._auth();
                  
                  
                  Severity: Minor
                  Found in app/src/components/keycloakAdminService.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

                  File dataService.js has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  const log = require('npmlog');
                  const Problem = require('api-problem');
                  const { transaction } = require('objection');
                  
                  class DataService {
                  Severity: Minor
                  Found in app/src/forms/common/dataService.js - About 2 hrs to fix

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

                      static get relationMappings() {
                        return {
                          attestation: {
                            relation: Model.HasOneRelation,
                            modelClass: this.Attestation,
                    Severity: Minor
                    Found in app/src/forms/attestations/models/submission.js - About 2 hrs to fix

                      Function up has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.up = function(knex) {
                        return Promise.resolve()
                          .then(() => knex.schema.createTable(`${PREFIX}_form`, table => {
                            table.uuid('formId').references('formId').inTable('form').notNullable().primary();
                            table.string('description');
                      Severity: Minor
                      Found in app/src/db/migrations/20200514140356_002-minesoperatorscreening.js - About 1 hr to fix

                        Function up has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        exports.up = function(knex) {
                          return knex(`${PREFIX}_version_status_code`).del()
                            .then(() => {
                              return knex(`${PREFIX}_status_code`).del();
                            })

                          Function updateSubmission has 48 lines of code (exceeds 25 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 1 hr to fix

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

                              constructor(slug, dataService) {
                                super();
                            
                                this._controller = new Controller(dataService);
                                this._resourceAccess = `comfort-${slug}`;
                            Severity: Minor
                            Found in app/src/forms/common/router.js - About 1 hr to fix

                              Function up has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              exports.up = function (knex) {
                                return Promise.resolve()
                                  .then(() => knex.schema.raw(`create view ${FARM_PREFIX}_submission_search_vw
                                          ("submissionId", "createdAt", deleted, "formVersionId", "confirmationId", "operationType", "assignedTo",
                                           "statusCode", "statusDate", name, city, "operationTypeDisplay", "statusDisplay")

                                Function down has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                exports.down = function(knex) {
                                  return Promise.resolve()
                                    .then(() => {
                                      return knex(`${PREFIX}_settings`).del();
                                    })

                                  Function down has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  exports.down = function(knex) {
                                    return Promise.resolve()
                                      .then(() => {
                                        return knex(`${PREFIX}_settings`).del();
                                      })
                                  Severity: Minor
                                  Found in app/src/db/migrations/20210506111303_020-farmopscreening-data.js - About 1 hr to fix

                                    Function down has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    exports.down = function(knex) {
                                      return Promise.resolve()
                                        .then(() => {
                                          return knex(`${PREFIX}_settings`).del();
                                        })

                                      Function update has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

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