Opetushallitus/eperusteet-opintopolku

View on GitHub
src/stores/OpetussuunnitelmaDataStore.ts

Summary

Maintainability
F
4 days
Test Coverage

OpetussuunnitelmaDataStore has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

@Store
export class OpetussuunnitelmaDataStore implements IOpetussuunnitelmaStore {
  @State() public opetussuunnitelma: OpetussuunnitelmaExportDto | null = null;
  @State() public opetussuunnitelmaPerusteenId: number | null = null;
  @State() public opetussuunnitelmaId: number;
Severity: Minor
Found in src/stores/OpetussuunnitelmaDataStore.ts - About 4 hrs to fix

    File OpetussuunnitelmaDataStore.ts has 325 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import _ from 'lodash';
    import { Getter, State, Store } from '@shared/stores/store';
    import { Location } from 'vue-router';
    import mime from 'mime-types';
    import { YlopsNavigationNodeDto,
    Severity: Minor
    Found in src/stores/OpetussuunnitelmaDataStore.ts - About 3 hrs to fix

      Function movePaikallisetOppiaineet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        movePaikallisetOppiaineet(navi: YlopsNavigationNodeDto) {
          const vieraatKielet = this.findByKoodi(navi, 'VK');
          if (!_.isEmpty(vieraatKielet)) {
            const paikallisetOppiaineet = this.findByTyyppi(navi, 'poppiaine');
            const paikallisetKielet = _(paikallisetOppiaineet)
      Severity: Minor
      Found in src/stores/OpetussuunnitelmaDataStore.ts - About 25 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 findBy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        findBy(navi: YlopsNavigationNodeDto, fn: (value: YlopsNavigationNodeDto) => boolean, parent: YlopsNavigationNodeDto | null = null): NavigationQueryResult[] {
          const kohde = _.get(navi, 'meta.koodi');
      
          const result: NavigationQueryResult[] = [];
      
      
      Severity: Minor
      Found in src/stores/OpetussuunnitelmaDataStore.ts - About 25 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

        @Getter((state, getters) => {
          if (!getters.sidenav) {
            return null;
          }
      
      
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 1 other location - About 1 day to fix
      src/stores/PerusteDataStore.ts on lines 168..190

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

      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 3 locations. Consider refactoring.
      Open

        @Getter((state, getters) => {
          const root = getters.sidenav;
          const result: Array<NavigationNode> = [];
      
          function traverseTree(node: NavigationNode) {
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 2 other locations - About 5 hrs to fix
      src/stores/PerusteDataStore.ts on lines 202..221
      src/stores/ToteutussuunnitelmaDataStore.ts on lines 179..198

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

      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

        @Getter(state => {
          if (!state.opetussuunnitelma || !state.navigation) {
            return null;
          }
          else {
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 1 other location - About 4 hrs to fix
      src/stores/ToteutussuunnitelmaDataStore.ts on lines 165..177

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

      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

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

        @Getter((state, getters) => {
          if (getters.flattenedSidenav && state.currentRoute) {
            for (const node of getters.flattenedSidenav) {
              if (node.location && _.isMatch(state.currentRoute, node.location)) {
                return node || null;
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 2 other locations - About 3 hrs to fix
      src/stores/PerusteDataStore.ts on lines 223..233
      src/stores/ToteutussuunnitelmaDataStore.ts on lines 204..214

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

      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

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

        @Getter((state, getters) => {
          if (state.sidenavFilter.isEnabled) {
            return filterNavigation(getters.sidenav, state.sidenavFilter);
          }
          else {
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 2 other locations - About 1 hr to fix
      src/stores/PerusteDataStore.ts on lines 192..200
      src/stores/ToteutussuunnitelmaDataStore.ts on lines 155..163

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

      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 rawKoodit = _.chain(getters.flattenedSidenav)
            .filter(node => node.type === 'oppiaine' || node.type === 'poppiaine')
            .filter('meta.koodi')
            .filter(node => _.isString(node.meta.koodi))
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 1 other location - About 1 hr to fix
      src/stores/OpetussuunnitelmaDataStore.ts on lines 323..326

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

      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 koodit = _.chain(getters.flattenedSidenav)
            .filter(node => node.type === 'oppiaine' || node.type === 'poppiaine')
            .filter('meta.koodi.uri')
            .keyBy('meta.koodi.uri')
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 1 other location - About 1 hr to fix
      src/stores/OpetussuunnitelmaDataStore.ts on lines 329..332

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

      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

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

        constructor(opetussuunnitelmaId: number, revision) {
          this.opetussuunnitelmaId = opetussuunnitelmaId;
          this.esikatselu = revision === '0' ? true : undefined;
          this.revision = revision;
        }
      Severity: Major
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 1 other location - About 1 hr to fix
      src/stores/ToteutussuunnitelmaDataStore.ts on lines 40..44

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

      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

        public static async create(opetussuunnitelmaId: number, revision: number | undefined = undefined) {
          const result = new OpetussuunnitelmaDataStore(opetussuunnitelmaId, revision);
          await result.init();
          return result;
        }
      Severity: Minor
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 1 other location - About 50 mins to fix
      src/stores/ToteutussuunnitelmaDataStore.ts on lines 46..50

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

      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

        async fetchTermit() {
          this.termit = null;
          this.termit = (await Termisto.getAllTermit(this.opetussuunnitelmaId)).data;
        }
      Severity: Minor
      Found in src/stores/OpetussuunnitelmaDataStore.ts and 1 other location - About 40 mins to fix
      src/stores/Lops2019LaajaAlaisetStore.ts on lines 19..22

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

      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

      There are no issues that match your filters.

      Category
      Status