Ks89/angular-modal-gallery

View on GitHub

Showing 513 of 513 total issues

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

export const LIBCONFIG_606: ModalLibConfig = {
  currentImageConfig: {
    description: {
      strategy: DescriptionStrategy.ALWAYS_VISIBLE,
      imageText: 'Look this image ',
Severity: Major
Found in examples/universal/src/app/modal-gallery/libconfigs.ts and 3 other locations - About 3 hrs to fix
examples/angular-cli-18/src/app/modal-gallery/libconfigs.ts on lines 404..425
examples/angular-cli-material/src/app/modal-gallery/libconfigs.ts on lines 404..425
src/app/modal-gallery/libconfigs.ts on lines 404..425

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

        it(`should call setConfig to update the library configuration with an undefined carouselConfig`,
          inject([ConfigService], (service: ConfigService) => {
            const inputConfig: LibConfig = {
              carouselConfig: undefined
            };
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 87..96
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 138..147
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 168..177
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 309..318
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 373..382
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 492..501
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 521..530
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 644..653
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 673..682

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

        it(`should call setConfig to update the library configuration with an undefined carouselPlayConfig`,
          inject([ConfigService], (service: ConfigService) => {
            const inputConfig: LibConfig = {
              carouselPlayConfig: undefined
            };
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 87..96
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 138..147
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 168..177
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 309..318
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 373..382
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 492..501
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 521..530
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 612..621
projects/ks89/angular-modal-gallery/src/lib/services/config.service.spec.ts on lines 673..682

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

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

      configService.setConfig(GALLERY_ID, {
        currentImageConfig: {
          loadingConfig: {enable: true, type: LoadingType.STANDARD} as LoadingConfig,
          description: {strategy: DescriptionStrategy.ALWAYS_VISIBLE} as Description
        },
projects/ks89/angular-modal-gallery/src/lib/components/current-image/current-image.component.spec.ts on lines 1304..1311

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

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

      configService.setConfig(GALLERY_ID, {
        currentImageConfig: {
          loadingConfig: {enable: true, type: LoadingType.STANDARD} as LoadingConfig,
          description: {strategy: DescriptionStrategy.ALWAYS_VISIBLE} as Description
        },
projects/ks89/angular-modal-gallery/src/lib/components/current-image/current-image.component.spec.ts on lines 1267..1274

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

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 NAVIGATION_NEXT_PREVIEWS: NavigationTestData[] = [
  {
    initial: {start: 0, end: 3, activeIndex: 0},
    expected: {start: 1, end: 4, activeIndex: 0}
  },
projects/ks89/angular-modal-gallery/src/lib/components/previews/previews.component.spec.ts on lines 141..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 104.

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 NAVIGATION_PREV_PREVIEWS: NavigationTestData[] = [
  {
    initial: {start: 2, end: 5, activeIndex: 0},
    expected: {start: 1, end: 4, activeIndex: 0}
  },
projects/ks89/angular-modal-gallery/src/lib/components/previews/previews.component.spec.ts on lines 130..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 104.

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 applyStyle has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  private applyStyle(): void {
    if (!this.description) {
      return;
    }

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

CurrentImageComponent has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

@Component({
  selector: 'ks-current-image',
  styleUrls: ['current-image.scss', '../image-arrows.scss', 'current-image-previews.scss'],
  templateUrl: 'current-image.html',
  changeDetection: ChangeDetectionStrategy.OnPush

    Function ngOnChanges has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      ngOnChanges(changes: SimpleChanges): void {
        const simpleChange: SimpleChange = changes.currentImage;
        if (!simpleChange) {
          return;
        }

    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

    ModalGalleryComponent has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
      selector: 'ks-modal-gallery',
      templateUrl: './modal-gallery.component.html',
      styleUrls: ['./modal-gallery.component.scss'],
      changeDetection: ChangeDetectionStrategy.OnPush

      File carousel-previews.component.ts has 290 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
       The MIT License (MIT)
      
       Copyright (c) 2017-2024 Stefano Cappa (Ks89)
      
      

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

                configService.setConfig(GALLERY_ID, {
                  accessibilityConfig: KS_DEFAULT_ACCESSIBILITY_CONFIG,
                  plainGalleryConfig: {
                    strategy: PlainGalleryStrategy.ROW,
                    layout: new LineLayout(
        projects/ks89/angular-modal-gallery/src/lib/components/plain-gallery/plain-gallery.component.spec.ts on lines 398..409

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

        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

              configService.setConfig(GALLERY_ID, {
                accessibilityConfig: KS_DEFAULT_ACCESSIBILITY_CONFIG,
                plainGalleryConfig: {
                  strategy: PlainGalleryStrategy.ROW,
                  layout: new LineLayout(
        projects/ks89/angular-modal-gallery/src/lib/components/plain-gallery/plain-gallery.component.spec.ts on lines 488..499

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

        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 handleTouch has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

          @HostListener('touchstart', ['$event'])
          @HostListener('touchend', ['$event'])
          @HostListener('touchcancel', ['$event'])
          handleTouch(event: TouchEvent) {
            let touch = event.touches[0] || event.changedTouches[0];

        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

            notValidIds.forEach((val: number, index: number) => {
              it(`should call checkAndAdd with bad inputs expecting an error as result. Test i=${index}`,
                inject([IdValidatorService], (service: IdValidatorService) => {
                  expect(() => service.checkAndAdd(val)).toThrow(new Error(errorMessage));
                })
        projects/ks89/angular-modal-gallery/src/lib/services/id-validator.service.spec.ts on lines 125..131

        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

            notValidIds.forEach((val: number, index: number) => {
              it(`should call remove with bad inputs expecting an error as result. Test i=${index}`,
                inject([IdValidatorService], (service: IdValidatorService) => {
                  expect(() => service.remove(val)).toThrow(new Error(errorMessage));
                })
        projects/ks89/angular-modal-gallery/src/lib/services/id-validator.service.spec.ts on lines 62..68

        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

        @Component({
          selector: 'ks-test-fallback-image-wrong',
          template: `
            <img src="wrong-img-path.jpg" ksFallbackImage [fallbackImg]="null" (fallbackApplied)="onError(false)">
            <img src="wrong-img-path.jpg" ksFallbackImage [fallbackImg]="undefined" (fallbackApplied)="onError(false)">
        projects/ks89/angular-modal-gallery/src/lib/directives/click-outside.directive.spec.ts on lines 30..57

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

        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

        @Component({
          selector: 'ks-test-click-outside',
          template: `
            <div id="modal-gallery-wrapper"
                 ksClickOutside [clickOutsideEnable]="true"
        projects/ks89/angular-modal-gallery/src/lib/directives/fallback-image.directive.spec.ts on lines 52..69

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

        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 dots.component.spec.ts has 276 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         * Copyright (c) 2017-2024 Stefano Cappa (Ks89)
         *
         * Licensed under the Apache License, Version 2.0 (the "License");
         * you may not use this file except in compliance with the License.
          Severity
          Category
          Status
          Source
          Language