Opetushallitus/eperusteet-opintopolku

View on GitHub
eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/stateservice.ts

Summary

Maintainability
F
3 days
Test Coverage

Function setState has 128 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        this.setState = function(navi) {
            this.state = {};
            _.each(navi.sections, function(section) {
                section.$open = false;
                _.each(section.items, function(item) {

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

                if (selected && section) {
                    var menuItems = items || section.items;
                    var parent = selected.$parent;
                    while (_.isNumber(parent)) {
                        menuItems[parent].$header = true;
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/lukiostateservice.ts on lines 140..150
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 144..154
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 327..337

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

            function processSection(navi, index, cb) {
                section = navi.sections[index];
                if (index === 1) {
                    state.vlk = true;
                }
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/lukiostateservice.ts on lines 24..34
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 23..33

    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

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

                function setParentOppiaineHeader() {
                    if (selected && selected.$oppiaine._oppiaine) {
                        var found = _.find(items, function(item: any) {
                            return item.$oppiaine && "" + item.$oppiaine.id === "" + selected.$oppiaine._oppiaine;
                        });
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/lukiostateservice.ts on lines 52..61
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 51..60

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

    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

                    } else if (item.$osa) {
                        item.$selected = "" + $stateParams.tekstikappaleId === "" + item.$osa.id;
                        item.$hidden = item.depth > 0;
                    } else if (item.id === "laajaalaiset") {
                        item.$selected = $state.is(epEsitysSettings.perusopetusState + ".laajaalaiset");
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 78..83

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

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

                    tiedot: {
                        index: 0,
                        callback: function(item) {
                            item.$selected =
                                _.isArray(item.link) &&
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/lukiostateservice.ts on lines 92..100
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 93..101
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 105..113
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 114..122

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

    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

                _.each(states, function(value: any, key) {
                    if (_.endsWith($state.current.name, key)) {
                        processSection(navi, value.index, value.callback || angular.noop);
                        (value.actions || angular.noop)();
                    }
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/lukiostateservice.ts on lines 133..138
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 137..142

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

    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

                    vuosiluokkakokonaisuus: {
                        index: 1,
                        callback: function(item) {
                            if (item.$vkl) {
                                item.$selected = "" + $stateParams.vlkId === "" + item.$vkl.id;
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 123..133

    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

                            if (item.$oppiaine) {
                                item.$selected =
                                    "" + $stateParams.oppiaineId === "" + item.$oppiaine.id &&
                                    $stateParams.vlkId === "" + parentVlkId;
                            }
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 159..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 62.

    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 (item.$vkl) {
                                item.$header = "" + $stateParams.vlkId === "" + item.$vkl.id;
                                parentVlkId = item.$vkl.id;
                            }
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 152..155

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

    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