Opetushallitus/eperusteet-frontend-utils

View on GitHub

Showing 183 of 183 total issues

File NavigationBuilder.ts has 775 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { NavigationNodeDto, LokalisoituTekstiDto } from '../tyypit';
import _ from 'lodash';
import { Kielet } from '../stores/kieli';
import { Location } from 'vue-router';

Severity: Major
Found in vue/src/utils/NavigationBuilder.ts - About 1 day to fix

    Function setPerusteData has 307 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function setPerusteData(node: NavigationNode, rawNode: NavigationNodeDto) {
      switch (rawNode.type as string) {
      case 'viite':
      case 'taiteenala':
      case 'liite':
    Severity: Major
    Found in vue/src/utils/NavigationBuilder.ts - About 1 day to fix

      Function setOpetussuunnitelmaData has 271 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function setOpetussuunnitelmaData(node: NavigationNode, rawNode: NavigationNodeDto) {
        switch (rawNode.type as string) {
        case 'viite':
        case 'liite':
          // Route linkki
      Severity: Major
      Found in vue/src/utils/NavigationBuilder.ts - About 1 day to fix

        File perusteet.ts has 562 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Koulutustyyppi, KoulutustyyppiToteutus } from '@shared/tyypit';
        import _ from 'lodash';
        
        export const KoodistoLops2019LaajaAlaiset = 'laajaalainenosaaminenlops2021';
        
        
        Severity: Major
        Found in vue/src/utils/perusteet.ts - About 1 day to fix

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

                  link: (scope: any, element, attrs, ctrl) => {
                      let placeholderText = null;
                      let editingEnabled = (scope.editMode || "true") === "true";
                      let inlineEditor: boolean = true;
          
          
          Severity: Major
          Found in components/ckeditor/ckeditor.ts - About 1 day to fix

            File EditointiStore.ts has 432 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import * as _ from 'lodash';
            import Vue from 'vue';
            import VueScrollTo from 'vue-scrollto';
            import { reactive, computed } from '@vue/composition-api';
            import { Computed } from '../../utils/interfaces';
            Severity: Minor
            Found in vue/src/components/EpEditointi/EditointiStore.ts - About 6 hrs to fix

              Function view has 146 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                get view() {
                  const opsId = this.opsId;
                  const self = this;
                  return Vue.extend({
                    components: {
              Severity: Major
              Found in vue/src/components/EpContent/ImageExtension.ts - About 5 hrs to fix

                File eperusteet.ts has 386 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { axiosHandler, successfulResponseHandler } from './common';
                import { Configuration, DokumentitApiAxiosParamCreator, LiitetiedostotApiAxiosParamCreator } from '../generated/eperusteet';
                import axios, { AxiosInstance } from 'axios';
                import _ from 'lodash';
                import * as EperusteetApi from '../generated/eperusteet';
                Severity: Minor
                Found in vue/src/api/eperusteet.ts - About 5 hrs to fix

                  EditointiStore has 37 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export class EditointiStore {
                    private static allEditingEditors: EditointiStore[] = [];
                    private static router: VueRouter;
                    private static kayttajaProvider: KayttajaProvider;
                    private logger = createLogger(EditointiStore);
                  Severity: Minor
                  Found in vue/src/components/EpEditointi/EditointiStore.ts - About 4 hrs to fix

                    Function controller has 120 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            controller: ($scope, $timeout, $rootScope) => {
                                $scope.versions = [];
                    
                                const cleanTeksti = (richText: string): string => {
                                    let result = richText;
                    Severity: Major
                    Found in components/history/history.ts - About 4 hrs to fix

                      File ckeditor.ts has 326 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      angular.module("app")
                      .run(() => {
                          CKEDITOR.disableAutoInline = true;
                      })
                      .constant("editorLayouts", {
                      Severity: Minor
                      Found in components/ckeditor/ckeditor.ts - About 3 hrs to fix

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

                        export const themes = {
                          'koulutustyyppi_1': 'ammatillinen',
                          'koulutustyyppi_11': 'ammatillinen',
                          'koulutustyyppi_12': 'ammatillinen',
                          'koulutustyyppi_5': 'ammatillinen',
                        Severity: Major
                        Found in vue/src/utils/perusteet.ts and 1 other location - About 3 hrs to fix
                        vue/src/utils/perusteet.ts on lines 215..236

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

                        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 ktToState = {
                          'koulutustyyppi_1': 'ammatillinenperustutkinto',
                          'koulutustyyppi_11': 'ammattitutkinto',
                          'koulutustyyppi_12': 'erikoisammattitutkinto',
                          'koulutustyyppi_14': 'aikuistenlukiokoulutus',
                        Severity: Major
                        Found in vue/src/utils/perusteet.ts and 1 other location - About 3 hrs to fix
                        vue/src/utils/perusteet.ts on lines 72..93

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

                        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 view has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          get view() {
                            const handler = this.handler;
                            return Vue.extend({
                              components: {
                                TermiEditor,
                        Severity: Major
                        Found in vue/src/components/EpContent/TermiExtension.ts - About 3 hrs to fix

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

                            if (isModeDark) {
                              logger.info('Set dark mode');
                              _.each(links, link => {
                                if (link.hasAttribute('href') && _.includes(link.getAttribute('href'), 'favicon')) {
                                  const href = _.replace(link.getAttribute('href')!, 'favicon', 'favicon-inverted');
                          Severity: Major
                          Found in vue/src/utils/icon.ts and 1 other location - About 3 hrs to fix
                          vue/src/utils/icon.ts on lines 17..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 107.

                          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

                            else {
                              logger.info('Set light mode');
                              _.each(links, link => {
                                if (link.hasAttribute('href') && _.includes(link.getAttribute('href'), 'favicon')) {
                                  const href = _.replace(link.getAttribute('href')!, 'favicon-inverted', 'favicon');
                          Severity: Major
                          Found in vue/src/utils/icon.ts and 1 other location - About 3 hrs to fix
                          vue/src/utils/icon.ts on lines 8..16

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

                          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 resolveRouterMetaProps has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export async function resolveRouterMetaProps(to) {
                            let props = {};
                          
                            try {
                              for (const record of to.matched) {
                          Severity: Minor
                          Found in vue/src/utils/router.ts - About 3 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

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

                          export async function findTiedotteetBy(query: TiedotteetQuery) {
                            return Tiedotteet.findTiedotteetBy(
                              query.sivu,
                              query.sivukoko,
                              query.kieli,
                          Severity: Major
                          Found in vue/src/api/eperusteet.ts and 1 other location - About 3 hrs to fix
                          vue/src/api/amosaa.ts on lines 149..166

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

                          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 async function getJulkisetOpetussuunnitelmat(query: OpetussuunnitelmaQuery) {
                            return JulkinenApi.findOpetussuunnitelmatJulkaisut(
                              query.perusteenDiaarinumero,
                              query.perusteId,
                              query.organisaatio,
                          Severity: Major
                          Found in vue/src/api/amosaa.ts and 1 other location - About 3 hrs to fix
                          vue/src/api/eperusteet.ts on lines 316..333

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

                          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 'perusopetusoppiaine':
                              node.location = {
                                name: _.get(rawNode, 'meta.vlkId') ? 'opetussuunnitelmaperusopetusvuosiluokanoppiaine' : 'opetussuunnitelmaperusopetusoppiaine',
                                params: {
                                  oppiaineId: _.toString(rawNode.id),
                          Severity: Major
                          Found in vue/src/utils/NavigationBuilder.ts and 1 other location - About 3 hrs to fix
                          vue/src/utils/NavigationBuilder.ts on lines 283..291

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language