Opetushallitus/eperusteet-opintopolku

View on GitHub
eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts

Summary

Maintainability
F
1 wk
Test Coverage

File opsutils.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
Severity: Minor
Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 2 hrs to fix

    Function makeSisalto has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var makeSisalto = function(perusteOpVlk, tavoitteet, perusteOppiaine, laajaalaiset, sortHelper) {
            return _(tavoitteet)
                .each(function(item) {
                    var perusteSisaltoAlueet = perusteOpVlk ? _.indexBy(perusteOpVlk.sisaltoalueet, "tunniste") : {};
                    var perusteKohdealueet = perusteOppiaine ? _.indexBy(perusteOppiaine.kohdealueet, "id") : [];
    Severity: Minor
    Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 1 hr to fix

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

          function buildOppiaineItem(arr, oppiaine, vlk, depth, isSisalto, currentVuosi, opts) {
              if (!oppiaine.nimi[Kieli.getSisaltokieli()]) {
                  return;
              }
              var vlkId = vlk ? vlkMap[vlk]["id"] : null;
      Severity: Minor
      Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 1 hr to fix

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

            function traverseOppiaineet(aineet, arr, vlk, startingDepth, currentVuosi, years) {
                var depth = startingDepth || 0;
                var currentYears =
                    years ||
                    arr[arr.length - 1].vlk.fi.replace(/\D/g, "").split("") ||
        Severity: Minor
        Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 1 hr to fix

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

              var rakennaVuosiluokkakokonaisuuksienMenu = function(vlkt, aineet) {
                  vlkMap = _.indexBy(vlkt, "_tunniste");
                  var vlkWithYears = createMenuByYear(vlkt);
                  var arr = [];
                  var lastVlk = null;
          Severity: Minor
          Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 1 hr to fix

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

                function buildOppiaineItem(arr, oppiaine, vlk, depth, isSisalto, currentVuosi, opts) {
            Severity: Major
            Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 50 mins to fix

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

                  function traverseOppiaineet(aineet, arr, vlk, startingDepth, currentVuosi, years) {
              Severity: Minor
              Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 45 mins to fix

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

                    var makeSisalto = function(perusteOpVlk, tavoitteet, perusteOppiaine, laajaalaiset, sortHelper) {
                Severity: Minor
                Found in eperusteet-opintopolku-app/yo/app/scripts/views/ops/opsutils.ts - About 35 mins to fix

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

                      var rakennaVuosiluokkakokonaisuuksienMenu = function(vlkt, aineet) {
                          vlkMap = _.indexBy(vlkt, "_tunniste");
                          var vlkWithYears = createMenuByYear(vlkt);
                          var arr = [];
                          var lastVlk = null;
                  eperusteet-opintopolku-app/yo/app/scripts/common/services/opsmenubuilders.ts on lines 42..77

                  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

                                      function(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/common/services/opsmenubuilders.ts on lines 128..139

                  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

                      var rakennaOppiaineetMenu = function(oppiaineet) {
                          var 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/common/services/opsmenubuilders.ts on lines 203..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 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

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

                                          item.sisaltoalueet = item.sisaltoalueet.sort(function(a, b) {
                                              if (
                                                  sortHelper.indexOf(a.sisaltoalueet.nimi.fi) >
                                                  sortHelper.indexOf(b.sisaltoalueet.nimi.fi)
                                              ) {
                  eperusteet-opintopolku-app/yo/app/scripts/common/services/opsutils.ts on lines 75..89

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

                  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

                          var createYears = function(numbs, tunniste) {
                              var start = parseInt(numbs[0]);
                              var stop = numbs[1] ? parseInt(numbs[1]) + 1 : start + 1;
                              for (var i = start; i < stop; i++) {
                                  menu.push({
                  eperusteet-opintopolku-app/yo/app/scripts/common/services/opsmenubuilders.ts on lines 20..30

                  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

                      var createEachYearLabel = function(arr, currentYears) {
                          var currentVlkt = [];
                          var start = parseInt(currentYears[0]);
                          var stop = currentYears[1] ? parseInt(currentYears[1]) + 1 : start + 1;
                          for (var i = start; i < stop; i++) {
                  eperusteet-opintopolku-app/yo/app/scripts/common/services/opsmenubuilders.ts on lines 80..88

                  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

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

                                          item.$sisaltoalueet = alueet.sort(function(a: any, b: any) {
                                              if (sortHelper.indexOf(a.nimi.fi) > sortHelper.indexOf(b.nimi.fi)) {
                                                  return 1;
                                              }
                                              if (sortHelper.indexOf(a.nimi.fi) < sortHelper.indexOf(b.nimi.fi)) {
                  eperusteet-opintopolku-app/yo/app/scripts/common/services/opsutils.ts on lines 66..74

                  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);
                              var nimi = v.nimi.fi || v.nimi.sv;
                              var numbs = nimi.replace(/\D/g, "").split("");
                              createYears(numbs, v._tunniste);
                  eperusteet-opintopolku-app/yo/app/scripts/common/services/opsmenubuilders.ts on lines 31..36

                  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

                          var 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/common/services/opsmenubuilders.ts on lines 110..113

                  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/common/services/opsmenubuilders.ts on lines 168..180

                  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), 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/common/services/opsmenubuilders.ts on lines 145..150

                  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/common/services/opsmenubuilders.ts on lines 181..189

                  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

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

                              .sortBy(function(vlk: any) {
                                  return _.reduce(
                                      vlk.nimi.fi.replace(/\D/g, "").split(""),
                                      function(sum, num: any) {
                                          return sum + parseInt(num, 10);
                  eperusteet-opintopolku-app/yo/app/scripts/common/services/opsutils.ts on lines 21..29

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

                  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