Opetushallitus/eperusteet-opintopolku

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

Summary

Maintainability
F
4 days
Test Coverage

Function setState has 109 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 3 locations. Consider refactoring.
    Open

            function processSection(navi, index, cb) {
                section = navi.sections[index];
                if (index === 1) {
                    state.oppiaine = true;
                }
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/stateservice.ts on lines 30..40
    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

    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/stateservice.ts on lines 166..176
    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 7 locations. Consider refactoring.
    Open

                    kurssi: {
                        index: 1,
                        callback: function(item) {
                            if (item.$kurssi) {
                                item.$selected = "" + $stateParams.kurssiId === "" + item.$kurssi.id;
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/lukiostateservice.ts on lines 101..115
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 102..116
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 243..257
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 272..286
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 287..301
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 302..316

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

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

                    oppiaine: {
                        index: 1,
                        callback: function(item) {
                            if (item.$oppiaine) {
                                item.$selected = "" + $stateParams.oppiaineId === "" + item.$oppiaine.id;
    eperusteet-opintopolku-app/yo/app/eperusteet-esitys/services/lukiostateservice.ts on lines 116..130
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 102..116
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 243..257
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 272..286
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 287..301
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 302..316

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

    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/stateservice.ts on lines 55..64
    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 3 locations. Consider refactoring.
    Open

                _.each(navi.sections, function(section) {
                    section.$open = false;
                    _.each(section.items, function(item) {
                        item.$selected = false;
                        item.$header = false;
    eperusteet-opintopolku-app/yo/app/scripts/common/services/lukioopsstateservice.ts on lines 37..46
    eperusteet-opintopolku-app/yo/app/scripts/views/ops/opssivunaviutils.ts on lines 39..48

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

    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/stateservice.ts on lines 100..108
    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/stateservice.ts on lines 159..164
    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

    There are no issues that match your filters.

    Category
    Status