trailofbits/tubertc

View on GitHub
public/js/viewports.js

Summary

Maintainability
F
6 days
Test Coverage

Function Dashboard has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

var Dashboard = function() {
    // @todo For hangoutsMode, make the all non-primary video clickable
    this.container = null;
    this.elem = null;
    this.orientation = 0;
Severity: Minor
Found in public/js/viewports.js - About 7 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 Dashboard has 167 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Dashboard = function() {
    // @todo For hangoutsMode, make the all non-primary video clickable
    this.container = null;
    this.elem = null;
    this.orientation = 0;
Severity: Major
Found in public/js/viewports.js - About 6 hrs to fix

    Function Viewport has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    var Viewport = function(peerName, dashboard) {
        // This indicates that the viewport is that of itself
        this.isSelf = false;
    
        // @todo In the future, make use of peerName by utilizing it as a label. However,
    Severity: Minor
    Found in public/js/viewports.js - About 6 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 Viewport has 153 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var Viewport = function(peerName, dashboard) {
        // This indicates that the viewport is that of itself
        this.isSelf = false;
    
        // @todo In the future, make use of peerName by utilizing it as a label. However,
    Severity: Major
    Found in public/js/viewports.js - About 6 hrs to fix

      File viewports.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * @file Defines the dashboard and viewport UI components.
       */
      
      'use strict';
      Severity: Minor
      Found in public/js/viewports.js - About 4 hrs to fix

        Function placeViewports has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            this.placeViewports = function() {
                var layout;
        
                if (this.hangoutsMode) {
                    layout = this.gridForHangoutsMode();
        Severity: Minor
        Found in public/js/viewports.js - About 1 hr to fix

          Function gridForViewportNumber has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              this.gridForViewportNumber = function(viewports) {
                  if(viewports === 0) {
                      return { 
                          rows: 0, 
                          grid: [] 
          Severity: Minor
          Found in public/js/viewports.js - About 1 hr to fix

            Function setupIcons has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                this.setupIcons = function() {
                    var dimensions = _this.videoDimensions();
            
                    if (dimensions.limitingValue === 'width') {
                        var vidHeight = dimensions.dimensions[1];
            Severity: Minor
            Found in public/js/viewports.js - About 1 hr to fix

              Function bindClick has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  this.bindClick = function() {
                    // @todo FIXME: this sort of feels and looks kludgey, can we fix this?
                      var clickHandler = function() {
                          if (dashboard.hangoutsMode) {
                              var i = dashboard.viewportArray.indexOf(_this);
              Severity: Minor
              Found in public/js/viewports.js - About 1 hr to fix

                FIXME found
                Open

                      // @todo FIXME: this sort of feels and looks kludgey, can we fix this?
                Severity: Minor
                Found in public/js/viewports.js by fixme

                FIXME found
                Open

                            // @todo FIXME (UI): on double click, this causes a selection event to occur
                Severity: Minor
                Found in public/js/viewports.js by fixme

                FIXME found
                Open

                        // @todo FIXME: there has to be a better mechanism for this?
                Severity: Minor
                Found in public/js/viewports.js by fixme

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

                        } else {
                            hangoutsViewport.elem.css({ height: '100%', 'padding-bottom': 0 });
                
                            dashboard.rowArray[0].css({
                                width: '80%',
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 2 hrs to fix
                public/js/viewports.js on lines 386..397

                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

                        if (dashboard.orientation === 'landscape') {
                            hangoutsViewport.elem.css({ width: '100%', 'padding-right': 0 });
                
                            dashboard.rowArray[0].css({
                                height: '85%',
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 2 hrs to fix
                public/js/viewports.js on lines 397..408

                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

                    this.showHangoutsMode = function() {
                        this.hangoutsMode = true;
                        if (this.viewportArray.length > 1) {
                            this.placeViewports();
                        }
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 1 hr to fix
                public/js/viewports.js on lines 487..492

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

                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

                    this.showDashMode = function() {
                        this.hangoutsMode = false;
                        if (this.viewportArray.length > 1) {
                            this.placeViewports();
                        }
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 1 hr to fix
                public/js/viewports.js on lines 500..505

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

                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

                        } else {
                            this.videoSrc
                                .stop(true, false)
                                .fadeOut(function() {
                                    _this.userIcon
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 1 hr to fix
                public/js/viewports.js on lines 140..148

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

                            } else {
                                row = $('<div></div>', { 'class': 'trtc_column' });
                                row.css({ width: 100 / layout.rows + '%', top: rowOffset });
                            }
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 1 hr to fix
                public/js/viewports.js on lines 334..337

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 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.
                Open

                            if (this.orientation === 'landscape') {
                                row = $('<div></div>', { 'class': 'trtc_row' });
                                row.css({ height: 100 / layout.rows + '%', left: rowOffset });
                            } else {
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 1 hr to fix
                public/js/viewports.js on lines 337..340

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

                        if (state) {
                            this.userIcon
                                .stop(true, false)
                                .fadeOut(function() {
                                    _this.videoSrc
                Severity: Major
                Found in public/js/viewports.js and 1 other location - About 1 hr to fix
                public/js/viewports.js on lines 148..156

                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

                Parsing error: The keyword 'const' is reserved
                Open

                        const maxItemCountInRow = 5;
                Severity: Minor
                Found in public/js/viewports.js by eslint

                For more information visit Source: http://eslint.org/docs/rules/

                There are no issues that match your filters.

                Category
                Status