Opetushallitus/eperusteet-frontend-utils

View on GitHub

Showing 183 of 183 total issues

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

  case 'perusopetusoppiaine':
    node.location = {
      name: _.get(rawNode, 'meta.vlkId') ? 'opetussuunnitelmaperusopetusvuosiluokanoppiaine' : 'opetussuunnitelmaperusopetusoppiaine',
      params: {
        oppiaineId: _.toString(rawNode.id),
Severity: Major
Found in vue/src/utils/NavigationBuilder.ts and 1 other location - About 3 hrs to fix
vue/src/utils/NavigationBuilder.ts on lines 283..291

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

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

Function iterateTunnisteelliset has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    export const iterateTunnisteelliset = (obj: Object, cb: (tunniste: string, obj) => boolean | void) => {
        const cache = {}; // Cycle detection
        const stack = [obj]; // Recursion elimination

        while (stack.length > 0) {
Severity: Minor
Found in components/history/history.ts - About 2 hrs 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

export interface IKasiteHandler {
  /**
   * Hae yksi termi termin avainarvolla (UUID)
   */
  getOne: (avain: string) => Promise<ITermi>,
Severity: Major
Found in vue/src/components/EpContent/KasiteHandler.ts and 1 other location - About 2 hrs to fix
vue/src/stores/kuvat.ts on lines 14..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 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 2 locations. Consider refactoring.
Open

export interface IKasiteHandler {
  /**
   * Hae yksi termi termin avainarvolla (UUID)
   */
  getOne: (avain: string) => Promise<TermiDto>,
Severity: Major
Found in vue/src/stores/kuvat.ts and 1 other location - About 2 hrs to fix
vue/src/components/EpContent/KasiteHandler.ts on lines 19..34

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

        figcaption: {
          get() {
            return (this as any).node.attrs['figcaption'];
          },
          set(value: any) {
Severity: Major
Found in vue/src/components/EpContent/ImageExtension.ts and 1 other location - About 2 hrs to fix
vue/src/components/EpContent/ImageExtension.ts on lines 155..164

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

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

        altText: {
          get() {
            return (this as any).node.attrs['alt'];
          },
          set(value: any) {
Severity: Major
Found in vue/src/components/EpContent/ImageExtension.ts and 1 other location - About 2 hrs to fix
vue/src/components/EpContent/ImageExtension.ts on lines 165..174

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

File editointikontrollit.ts has 278 lines of code (exceeds 250 allowed). Consider refactoring.
Open

interface IEditointikontrollitCallbacks {
    start?: (val?) => Promise<any>,
    preStart?: () => Promise<any>,
    preSave?: () => Promise<any>,
    save?: (kommentti?, preSavedObject?) => Promise<any>,
Severity: Minor
Found in components/editointikontrollit/editointikontrollit.ts - About 2 hrs to fix

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

        if (_.get(rawNode.meta, 'vapaateksti_id')) {
          node.location = {
            name: 'tekstikappaleVapaaOsa',
            params: {
              vapaatekstiId: _.get(rawNode.meta, 'vapaateksti_id') as any,
    Severity: Major
    Found in vue/src/utils/NavigationBuilder.ts and 1 other location - About 2 hrs to fix
    vue/src/utils/NavigationBuilder.ts on lines 341..349

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

    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

    Function link has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                link: function (scope: any, element) {
                    scope.popovers = [];
    
                    function destroy() {
                        element.find(TERMI_MATCHER).each(function () {
    Severity: Major
    Found in components/termisto/termisto.ts - About 2 hrs to fix

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

          if (_.get(rawNode.meta, 'alaosa')) {
            node.location = {
              name: 'tekstikappaleOsa',
              params: {
                osa: _.get(rawNode.meta, 'alaosa') as any,
      Severity: Major
      Found in vue/src/utils/NavigationBuilder.ts and 1 other location - About 2 hrs to fix
      vue/src/utils/NavigationBuilder.ts on lines 331..339

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

      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

      Function createRestangular has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          export const createRestangular = (
              scope,
              field: string,
              resolvedObj: Restangular.IElement,
              callbacks: IEditointikontrollitCallbacks = {}) => {
      Severity: Major
      Found in components/editointikontrollit/editointikontrollit.ts - About 2 hrs to fix

        Function directive has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            export const directive = ($parse, $timeout) => {
        
                const checkInputType = (scope) => {
        
                    scope.datePicker = {
        Severity: Major
        Found in components/datepicker/datepicker.ts - About 2 hrs to fix

          Function view has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            get view() {
              const opsId = this.opsId;
              const self = this;
              return Vue.extend({
                components: {
          Severity: Minor
          Found in vue/src/components/EpContent/ImageExtension.ts - About 2 hrs 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 kaanna has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            public kaanna(value?: LokalisoituTeksti | undefined | null, emptyWhenNotFound = false, squareBrackets = true, forcedLang = null): string {
              if (!value) {
                return '';
              }
              else if (_.isObject(value)) {
          Severity: Minor
          Found in vue/src/stores/kieli.ts - About 2 hrs 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 open has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  async open() {
                    if (!this.view.editable) {
                      return;
                    }
          
          
          Severity: Major
          Found in vue/src/components/EpContent/ImageExtension.ts - About 2 hrs to fix

            Function view has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              get view() {
                const handler = this.handler;
                return Vue.extend({
                  components: {
                    TermiEditor,
            Severity: Minor
            Found in vue/src/components/EpContent/TermiExtension.ts - About 2 hrs 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

                $scope.widthChange = (img) => {
                    $scope.scaleError = false;
                    const tmp = img.width / img.originalWidth;
                    img.height = Math.round(tmp * img.originalHeight);
                };
            Severity: Major
            Found in components/ckeditor/kuvat.ts and 1 other location - About 1 hr to fix
            components/ckeditor/kuvat.ts on lines 136..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 74.

            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

                $scope.heightChange = (img) => {
                    $scope.scaleError = false;
                    const tmp = img.height / img.originalHeight;
                    img.width = Math.round(tmp * img.originalWidth);
                };
            Severity: Major
            Found in components/ckeditor/kuvat.ts and 1 other location - About 1 hr to fix
            components/ckeditor/kuvat.ts on lines 130..134

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

            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

            Function rakenneNodecolor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            export function rakenneNodecolor(node, parentMandatory, el) {
              const isRyhma = !!node.rooli;
            
              if (isRyhma) {
                const mapped = RooliToTheme[node.rooli];
            Severity: Minor
            Found in vue/src/utils/perusterakenne.ts - About 1 hr 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 start has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public async start() {
                this.state.disabled = true;
                this.state.isLoading = true;
            
                // Ei editointia uudestaan
            Severity: Minor
            Found in vue/src/components/EpEditointi/EditointiStore.ts - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language