harella1/video.js

View on GitHub
src/js/component.js

Summary

Maintainability
F
5 days
Test Coverage

File component.js has 556 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @file component.js
 *
 * Player Component - Base class for all UI objects
 */
Severity: Major
Found in src/js/component.js - About 1 day to fix

    Component has 50 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Component {
    
      constructor(player, options, ready) {
    
        // The component might be the player itself and we can't pass `this` to super
    Severity: Minor
    Found in src/js/component.js - About 7 hrs to fix

      Function initChildren has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        initChildren() {
          let children = this.options_.children;
      
          if (children) {
            // `this` is `parent`
      Severity: Major
      Found in src/js/component.js - About 2 hrs to fix

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

          initChildren() {
            let children = this.options_.children;
        
            if (children) {
              // `this` is `parent`
        Severity: Minor
        Found in src/js/component.js - 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 addChild has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          addChild(child, options={}, index=this.children_.length) {
            let component;
            let componentName;
        
            // If child is a string, create nt with options
        Severity: Minor
        Found in src/js/component.js - 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 emitTapEvents has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          emitTapEvents() {
            // Track the start time so we can determine how long the touch lasted
            let touchStart = 0;
            let firstTouch = null;
        
        
        Severity: Minor
        Found in src/js/component.js - About 1 hr to fix

          Function addChild has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            addChild(child, options={}, index=this.children_.length) {
              let component;
              let componentName;
          
              // If child is a string, create nt with options
          Severity: Minor
          Found in src/js/component.js - About 1 hr to fix

            Function constructor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              constructor(player, options, ready) {
            
                // The component might be the player itself and we can't pass `this` to super
                if (!player && this.play) {
                  this.player_ = player = this; // eslint-disable-line
            Severity: Minor
            Found in src/js/component.js - 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 dimension has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              dimension(widthOrHeight, num, skipListeners) {
                if (num !== undefined) {
                  // Set to zero if null or literally NaN (NaN !== NaN)
                  if (num === null || num !== num) {
                    num = 0;
            Severity: Minor
            Found in src/js/component.js - 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 constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor(player, options, ready) {
            
                // The component might be the player itself and we can't pass `this` to super
                if (!player && this.play) {
                  this.player_ = player = this; // eslint-disable-line
            Severity: Minor
            Found in src/js/component.js - About 1 hr to fix

              Function ready has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                ready(fn, sync=false) {
                  if (fn) {
                    if (this.isReady_) {
                      if (sync) {
                        fn.call(this);
              Severity: Minor
              Found in src/js/component.js - 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 removeChild has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                removeChild(component) {
                  if (typeof component === 'string') {
                    component = this.getChild(component);
                  }
              
              
              Severity: Minor
              Found in src/js/component.js - 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 on has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                on(first, second, third) {
                  if (typeof first === 'string' || Array.isArray(first)) {
                    Events.on(this.el_, first, Fn.bind(this, second));
              
                  // Targeting another component or element
              Severity: Minor
              Found in src/js/component.js - 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 dispose has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                dispose() {
                  this.trigger({ type: 'dispose', bubbles: false });
              
                  // Dispose all children.
                  if (this.children_) {
              Severity: Minor
              Found in src/js/component.js - 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 off has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                off(first, second, third) {
                  if (!first || typeof first === 'string' || Array.isArray(first)) {
                    Events.off(this.el_, first, second);
                  } else {
                    const target = first;
              Severity: Minor
              Found in src/js/component.js - 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

              Function localize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                localize(string) {
                  let code = this.player_.language && this.player_.language();
                  let languages = this.player_.languages && this.player_.languages();
              
                  if (!code || !languages) {
              Severity: Minor
              Found in src/js/component.js - 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.
              Open

                static getComponent(name) {
                  if (Component.components_ && Component.components_[name]) {
                    return Component.components_[name];
                  }
              
              
              Severity: Major
              Found in src/js/component.js and 1 other location - About 3 hrs to fix
              src/js/tech/tech.js on lines 605..614

              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

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

                clearInterval(intervalId) {
                  window.clearInterval(intervalId);
              
                  const disposeFn = function() {};
              
              
              Severity: Major
              Found in src/js/component.js and 1 other location - About 1 hr to fix
              src/js/component.js on lines 1320..1330

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

              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

                clearTimeout(timeoutId) {
                  window.clearTimeout(timeoutId);
              
                  const disposeFn = function() {};
              
              
              Severity: Major
              Found in src/js/component.js and 1 other location - About 1 hr to fix
              src/js/component.js on lines 1363..1373

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

              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

                  for (let name in props) {
                    if (props.hasOwnProperty(name)) {
                      subObj.prototype[name] = props[name];
                    }
                  }
              Severity: Minor
              Found in src/js/component.js and 1 other location - About 40 mins to fix
              src/js/extend.js on lines 69..73

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

              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