Opetushallitus/eperusteet-frontend-utils

View on GitHub

Showing 71 of 183 total issues

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

  public async save() {
    this.state.disabled = true;
    this.state.isSaving = true;

    if (!this.isEditing.value) {
Severity: Minor
Found in vue/src/components/EpEditointi/EditointiStore.ts - About 1 hr to fix

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

        export const directive = ($window) => {
            return {
                templateUrl: "components/editointikontrollit/editointikontrollit.jade",
                restrict: "E",
                controller: controller,
    Severity: Minor
    Found in components/editointikontrollit/editointikontrollit.ts - About 1 hr to fix

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

          export const createListRestangular = (
              scope,
              field: string,
              resolvedObj: Restangular.IElement) => {
              scope[field] = resolvedObj.clone();
      Severity: Minor
      Found in components/editointikontrollit/editointikontrollit.ts - About 1 hr to fix

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

                    const doDiff = (oldVersion?, newVersion?) => {
                        oldVersion = oldVersion || $scope.currentHistoryItem;
                        newVersion = newVersion || $scope.data;
        
                        if (!oldVersion || !oldVersion[$scope.selectedLang]) {
        Severity: Minor
        Found in components/history/history.ts - About 1 hr to fix

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

            public static install(vue: typeof Vue, config: OikeustarkasteluConfig) {
              vue.prototype.$isAdmin = () => config.oikeusProvider.isAdmin?.value || false;
              vue.prototype.$hasOphCrud = () => config.oikeusProvider.hasOphCrud?.value || false;
          
              vue.prototype.$hasOikeus = function(oikeus: Oikeus, kohde?: any) {
          Severity: Minor
          Found in vue/src/plugins/oikeustarkastelu.ts - About 1 hr to fix

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

                export const FooterData = function ($http, $window, $q) {
                    let data = null;
                    let fetched = false;
                    const pattern = /([^=]+)=([^=]+)(?:\n|$)/gi;
                    this.fetch = function() {
            Severity: Minor
            Found in components/footer/footer.ts - About 1 hr to fix

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

              export function rakenneNodecolor(node, parentMandatory, el) {
                const isRyhma = !!node.rooli;
              
                if (isRyhma) {
                  const mapped = RooliToTheme[node.rooli];
              Severity: Minor
              Found in vue/src/utils/perusterakenne.ts - About 1 hr to fix

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

                export function yleissivastavatKoulutustyyppiRelaatiot() {
                  return [{
                    koulutustyyppi: 'koulutustyyppi_20',
                    alityypit: ['koulutustyyppi_20'],
                  }, {
                Severity: Minor
                Found in vue/src/utils/perusteet.ts - About 1 hr to fix

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

                              link: (scope, element, attrs, ngModel) => {
                                  let parsedMoment;
                                  ngModel.$parsers.unshift(function (viewValue) {
                                      return validate(viewValue);
                                  });
                  Severity: Minor
                  Found in components/datepicker/datepicker.ts - About 1 hr to fix

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

                                const getVersion = (modelValue?): Promise<any> => new Promise((resolve, reject) => {
                                    if (!_.isNumber(modelValue)) {
                                        modelValue = $scope.historySlider.value;
                                    }
                    
                    
                    Severity: Minor
                    Found in components/history/history.ts - About 1 hr to fix

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

                          const uusiViesti = (tyyppi, viesti, ilmanKuvaa?) => {
                              if (_.isObject(viesti) && viesti.data && viesti.data.syy) {
                                  viesti = viesti.data.syy;
                              }
                              else if (!viesti) {
                      Severity: Minor
                      Found in components/notifikaatiot/notifikaatiot.ts - 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

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

                          export const translate = (obj, key, useFallback) => {
                              const getTranslation = (input, lang) => {
                                  return input[lang] || input[lang.toUpperCase()] || input["kieli_" + lang + "#1"];
                              };
                      
                      
                      Severity: Minor
                      Found in components/lokalisointi/kaanna.ts - 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

                      Function update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public async update() {
                          if (this.state.perusteId) {
                            if (this.state.muokkaustiedot && !_.isEmpty(this.state.muokkaustiedot)) {
                              this.state.viimeinenHaku = (await Muokkaustiedot.getPerusteenMuokkausTiedotWithLuomisaika(this.state.perusteId, (_.last(this.state.muokkaustiedot) as any).luotu, this.state.hakuLukumaara) as any).data;
                      
                      
                      Severity: Minor
                      Found in vue/src/stores/MuokkaustietoStore.ts - About 45 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 (id && !(id in cache)) {
                                                  cache[id] = true;
                                                  stack.push(head[key]);
                                              }
                      Severity: Major
                      Found in components/history/history.ts - About 45 mins to fix

                        Function muokkaustietoRoute has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        export function muokkaustietoRoute(id, kohde, tapahtuma, tyyppi = 'ops', lisaparametrit?) {
                        Severity: Minor
                        Found in vue/src/utils/tapahtuma.ts - About 35 mins to fix

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

                            public async start() {
                              this.state.disabled = true;
                              this.state.isLoading = true;
                          
                              // Ei editointia uudestaan
                          Severity: Minor
                          Found in vue/src/components/EpEditointi/EditointiStore.ts - 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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            public async save() {
                              this.state.disabled = true;
                              this.state.isSaving = true;
                          
                              if (!this.isEditing.value) {
                          Severity: Minor
                          Found in vue/src/components/EpEditointi/EditointiStore.ts - 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 setUiKieli has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              export const setUiKieli = (kielikoodi, doStateChange?) => {
                                  if (isValidKielikoodi(kielikoodi) &&
                                          (kielikoodi !== uikieli || (stateInited && _$stateParams.lang !== kielikoodi))) {
                                      if (_.isUndefined(doStateChange) || doStateChange === true) {
                                          _$state.go(_$state.current.name, _.merge(_$stateParams, {lang: kielikoodi}), {reload: true});
                          Severity: Minor
                          Found in components/lokalisointi/kieli.ts - 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

                          Avoid too many return statements within this function.
                          Open

                            return [koulutustyyppi];
                          Severity: Major
                          Found in vue/src/utils/perusteet.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return ColorMap.pakollinen;
                            Severity: Major
                            Found in vue/src/utils/perusterakenne.ts - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language