Opetushallitus/eperusteet-opintopolku

View on GitHub
eperusteet-opintopolku-app/yo/app/scripts/common/services/opsmenubuilders.ts

Summary

Maintainability
F
6 days
Test Coverage

File opsmenubuilders.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2013 The Finnish Board of Education - Opetushallitus
 *
 * This program is free software: Licensed under the EUPL, Version 1.1 or - as
 * soon as they will be approved by the European Commission - subsequent versions

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

        function buildOppiaineItem(arr, oppiaine, vlk, depth, isSisalto, currentVuosi, opts) {
            if (!oppiaine.nimi[Kieli.getSisaltokieli()]) {
                return;
            }
    
    

      Function rakennaVuosiluokkakokonaisuuksienMenu has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const rakennaVuosiluokkakokonaisuuksienMenu = (vlkt, aineet) => {
              vlkMap = _.indexBy(vlkt, "_tunniste");
              let vlkWithYears = createMenuByYear(vlkt);
              let arr = [];
              let lastVlk = null;

        Function traverseOppiaineet has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function traverseOppiaineet(aineet, arr, vlk, startingDepth, currentVuosi, years) {
                let depth = startingDepth || 0;
                let currentYears =
                    years ||
                    arr[arr.length - 1].vlk.fi.replace(/\D/g, "").split("") ||

          Function buildOppiaineItem has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              function buildOppiaineItem(arr, oppiaine, vlk, depth, isSisalto, currentVuosi, opts) {

            Function traverseOppiaineet has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                function traverseOppiaineet(aineet, arr, vlk, startingDepth, currentVuosi, years) {

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

                  const rakennaVuosiluokkakokonaisuuksienMenu = (vlkt, aineet) => {
                      vlkMap = _.indexBy(vlkt, "_tunniste");
                      let vlkWithYears = createMenuByYear(vlkt);
                      let arr = [];
                      let lastVlk = null;
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 53..87

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

              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

                                  (col, item: any, index, all) => {
                                      if (item._vuosiluokkakokonaisuus === vlk) {
                                          _.isEmpty(item.vuosiluokat) ? col.unshift("all") : col.unshift(item.vuosiluokat);
                                      }
                                      if (all.length - 1 === index) {
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 119..130

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

              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 rakennaOppiaineetMenu = oppiaineet => {
                      let menu = [];
                      _.each(oppiaineSort(oppiaineet), function(oa) {
                          buildOppiaineItem(menu, oa, null, 0, null, null, { menuType: "oppiaineetMenu" });
                          if (oa.koosteinen && oa.oppimaarat.length > 0) {
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 182..193

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

              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 createYears = (numbs, tunniste) => {
                          let start = parseInt(numbs[0]);
                          let stop = numbs[1] ? parseInt(numbs[1]) + 1 : start + 1;
                          for (let i = start; i < stop; i++) {
                              menu.push({
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 33..43

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

              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 createEachYearLabel = (arr, currentYears) => {
                      let currentVlkt = [];
                      let start = parseInt(currentYears[0]);
                      let stop = currentYears[1] ? parseInt(currentYears[1]) + 1 : start + 1;
                      for (let i = start; i < stop; i++) {
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 88..96

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

              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

                      _.each(vlk, function(v) {
                          menu.push(v);
                          let nimi = v.nimi.fi || v.nimi.sv;
                          let numbs = nimi.replace(/\D/g, "").split("");
                          createYears(numbs, v._tunniste);
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 44..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 92.

              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

                      let currentYears =
                          years ||
                          arr[arr.length - 1].vlk.fi.replace(/\D/g, "").split("") ||
                          arr[arr.length - 1].vlk.sv.replace(/\D/g, "").split("");
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 109..112

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

              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

                      if (opts["menuType"] === "vuosiluokittain") {
                          oppiaineUrl = type
                              ? $state.href("root.ops.perusopetus.vuosiluokkakokonaisuus.vuosiluokka.oppiaine", {
                                    vlkId: vlkId,
                                    vuosi: currentYear,
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 150..162

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

              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

                      _.each(oppiaineSort(filteredAineet, vlk), function(oa) {
                          buildOppiaineItem(arr, oa, vlk, depth, isSisalto, currentVuosi, { menuType: "vuosiluokittain" });
                          if (oa.koosteinen && oa.oppimaarat.length > 0) {
                              traverseOppiaineet(oa.oppimaarat, arr, vlk, 3, currentVuosi, currentYears);
                          }
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 135..140

              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

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

                      if (opts["menuType"] === "oppiaineetMenu") {
                          oppiaineUrl = type
                              ? $state.href("root.ops.perusopetus.oppiaineet", {
                                    oppiaineId: oppiaine.id
                                })
              eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts on lines 163..171

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

              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

                          let target = _(item.vuosiluokkakokonaisuudet)
                              .filter(v => {
                                  return v._vuosiluokkakokonaisuus === vlk;
                              })
                              .map("jnro")
              eperusteet-opintopolku-app/yo/app/scripts/common/services/opsutils.ts on lines 44..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 49.

              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