lukemnet/tridi

View on GitHub
src/tridi.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

File tridi.ts has 658 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

/*
  Tridi v2.0.2 - JavaScript 360 3D Product Viewer
  Author: Lukasz Wojcik
  License: MIT
  Homepage: https://tridi.lukem.net
Severity: Major
Found in src/tridi.ts - About 1 day to fix

    Tridi has 54 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    export class Tridi {
      [key: string]: any;
    
      element: string | HTMLElement;
    
    
    Severity: Major
    Found in src/tridi.ts - About 7 hrs to fix

      Function constructor has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Invalid

        constructor(options: TridiOptions) {
          this.validate(options);
      
          this.element = options.element;
          this.images = options.images || 'numbered';
      Severity: Major
      Found in src/tridi.ts - About 2 hrs to fix

        Function displayHintOnStartup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Wontfix

          private displayHintOnStartup(callback: Function) {
            if (this.hintOnStartup) {
              const hintOverlayClassName = `tridi-${this.elementName}-hint-overlay`;
              const hintOverlay = document.createElement('div');
              hintOverlay.className += `tridi-hint-overlay ${hintOverlayClassName}`;
        Severity: Minor
        Found in src/tridi.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 startAutoplay has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Invalid

          private startAutoplay() {
            if (this.autoplay) {
              this.toggleAutoplay(true, true);
        
              if (this.stopAutoplayOnClick) {
        Severity: Minor
        Found in src/tridi.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 displayHintOnStartup has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

          private displayHintOnStartup(callback: Function) {
            if (this.hintOnStartup) {
              const hintOverlayClassName = `tridi-${this.elementName}-hint-overlay`;
              const hintOverlay = document.createElement('div');
              hintOverlay.className += `tridi-hint-overlay ${hintOverlayClassName}`;
        Severity: Minor
        Found in src/tridi.ts - About 1 hr to fix

          Function startAutoplay has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Wontfix

            private startAutoplay() {
              if (this.autoplay) {
                this.toggleAutoplay(true, true);
          
                if (this.stopAutoplayOnClick) {
          Severity: Minor
          Found in src/tridi.ts - About 1 hr to fix

            Function toggleAutoplay has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Wontfix

              private toggleAutoplay(state: boolean, skipDelay?: boolean) {
                if (state) {
                  this.clearTimeouts();
            
                  if (this.intervals.length === 0) {
            Severity: Minor
            Found in src/tridi.ts - About 45 mins 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 constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Wontfix

              constructor(options: TridiOptions) {
                this.validate(options);
            
                this.element = options.element;
                this.images = options.images || 'numbered';
            Severity: Minor
            Found in src/tridi.ts - About 35 mins 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 rotateViewerImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Wontfix

              private rotateViewerImage(e: MouseEvent | TouchEvent) {
                const touch = (e as TouchEvent).touches;
                const interval = (touch ? this.touchDragInterval : this.dragInterval)!;
            
                const clientX = (e as TouchEvent).touches
            Severity: Minor
            Found in src/tridi.ts - About 25 mins 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.
            Wontfix

              private setAutoplayTimeout() {
                const autoplayTimeout = window.setTimeout(
                  this.setAutoplayInterval.bind(this),
                  this.resumeAutoplayDelay,
                );
            Severity: Major
            Found in src/tridi.ts and 1 other location - About 1 hr to fix
            src/tridi.ts on lines 685..691

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

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

              private setAutoplayInterval() {
                const autoplayInterval = window.setInterval(
                  this.nextMove.bind(this),
                  this.autoplaySpeed,
                );
            Severity: Major
            Found in src/tridi.ts and 1 other location - About 1 hr to fix
            src/tridi.ts on lines 698..704

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

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

              private startDragging() {
                this.dragActive = true;
                this.viewer().classList.add('tridi-dragging');
                this.trigger('onDragStart');
              }
            Severity: Minor
            Found in src/tridi.ts and 1 other location - About 50 mins to fix
            src/tridi.ts on lines 572..576

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

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

              private stopDragging() {
                this.dragActive = false;
                this.viewer().classList.remove('tridi-dragging');
                this.trigger('onDragEnd');
              }
            Severity: Minor
            Found in src/tridi.ts and 1 other location - About 50 mins to fix
            src/tridi.ts on lines 566..570

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

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

              private prevMove() {
                this.trigger('onPrevMove');
                return this.inverse ? this.nextFrame() : this.prevFrame();
              }
            Severity: Minor
            Found in src/tridi.ts and 1 other location - About 35 mins to fix
            src/tridi.ts on lines 526..529

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

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

              private nextMove() {
                this.trigger('onNextMove');
                return this.inverse ? this.prevFrame() : this.nextFrame();
              }
            Severity: Minor
            Found in src/tridi.ts and 1 other location - About 35 mins to fix
            src/tridi.ts on lines 531..534

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

            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