Opetushallitus/eperusteet-frontend-utils

View on GitHub

Showing 183 of 183 total issues

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

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

              case 'suorituspolut':
                node.label = 'suorituspolut';
                node.location = {
                  name: 'toteutussuunnitelmaSuorituspolut',
                  params: {
            Severity: Major
            Found in vue/src/utils/NavigationBuilder.ts and 1 other location - About 1 hr to fix
            vue/src/utils/NavigationBuilder.ts on lines 647..655

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

            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

              case 'osaamismerkki':
                node.label = 'kansalliset-perustaitojen-osaamismerkit';
                node.location = {
                  name: 'toteutussuunnitelmaSisalto',
                  params: {
            Severity: Major
            Found in vue/src/utils/NavigationBuilder.ts and 1 other location - About 1 hr to fix
            vue/src/utils/NavigationBuilder.ts on lines 558..566

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

            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

            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

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

              export function success(title: string) {
                (Vue as any).notify({
                  title: Kielet.i18n.t(title),
                  type: 'success',
                });
              Severity: Minor
              Found in vue/src/utils/notifications.ts and 1 other location - About 55 mins to fix
              vue/src/utils/notifications.ts on lines 27..32

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

              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

                    if (syy) {
                      fail('poisto-epaonnistui', err.response.data.syy);
                    }
                    else {
                      this.logger.error('poisto-epaonnistui', err);
              Severity: Minor
              Found in vue/src/components/EpEditointi/EditointiStore.ts and 1 other location - About 55 mins to fix
              vue/src/components/EpEditointi/EditointiStore.ts on lines 466..472

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

              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

              export function info(title: string) {
                (Vue as any).notify({
                  title: Kielet.i18n.t(title),
                  type: 'info',
                });
              Severity: Minor
              Found in vue/src/utils/notifications.ts and 1 other location - About 55 mins to fix
              vue/src/utils/notifications.ts on lines 20..25

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

              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

                    if (syy) {
                      fail('palautus-epaonnistui', err.response.data.syy);
                    }
                    else {
                      this.logger.error('Palautus epäonnistui', err);
              Severity: Minor
              Found in vue/src/components/EpEditointi/EditointiStore.ts and 1 other location - About 55 mins to fix
              vue/src/components/EpEditointi/EditointiStore.ts on lines 399..405

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

              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

              export const julkaisupaikka = Object.freeze({
                opintopolku_etusivu: 'opintopolku_etusivu',
                ops: 'ops',
                lops: 'lops',
                amosaa: 'amosaa',
              Severity: Minor
              Found in vue/src/utils/tiedote.ts and 1 other location - About 55 mins to fix
              vue/src/utils/perusterakenne.ts on lines 41..49

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

              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

              export const ColorMap = Object.freeze({
                ammatilliset: '#b2b2b2',
                osaamisala: '#575757',
                paikalliset: '#c126b8',
                pakollinen: '#bdeaa1',
              Severity: Minor
              Found in vue/src/utils/perusterakenne.ts and 1 other location - About 55 mins to fix
              vue/src/utils/tiedote.ts on lines 15..23

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

              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

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

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

              const tyypitettyKohdereititysId = {
                'ops': { ...kohdereititysId },
                'normaali': { ...kohdereititysId, ...perusteKohdereititysId },
                'pohja': { ...kohdereititysId, ...perusteKohdereititysId },
                'opas': { ...kohdereititysId, ...perusteKohdereititysId },
              Severity: Minor
              Found in vue/src/utils/tapahtuma.ts and 1 other location - About 55 mins to fix
              vue/src/utils/tapahtuma.ts on lines 33..38

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

              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

              const tyypitettyReititys = {
                'ops': { ...oletusKohdereititys },
                'normaali': { ...oletusKohdereititys, ...perusteKohdeReititys },
                'pohja': { ...oletusKohdereititys, ...perusteKohdeReititys },
                'opas': { ...oletusKohdereititys, ...opasKohdeReititys },
              Severity: Minor
              Found in vue/src/utils/tapahtuma.ts and 1 other location - About 55 mins to fix
              vue/src/utils/tapahtuma.ts on lines 61..66

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

              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

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

                Severity
                Category
                Status
                Source
                Language