ocadotechnology/rapid-router

View on GitHub
game/static/game/js/character.js

Summary

Maintainability
F
4 days
Test Coverage

File character.js has 465 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var ocargo = ocargo || {};

ocargo.circumference = function (radius) {
Severity: Minor
Found in game/static/game/js/character.js - About 7 hrs to fix

    Function turnAround has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ocargo.Character.prototype.turnAround = function (direction) {
        var that = this;
    
        var actions = [];
        var index = 0;
    Severity: Major
    Found in game/static/game/js/character.js - About 3 hrs to fix

      Function scrollToShow has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      ocargo.Character.prototype.scrollToShow = function () {
          var dx = 150;
          var dy = 150;
      
          this.skipOutstandingAnimations();
      Severity: Minor
      Found in game/static/game/js/character.js - About 1 hr to fix

        Function _animateCollision has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        ocargo.Character.prototype._animateCollision = function (withFire) {
            if (this.isVeilOfNight) {
                return function () {
                };
            }
        Severity: Minor
        Found in game/static/game/js/character.js - About 1 hr to fix

          Function Character has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          ocargo.Character = function (paper, imageUrl, wreckageImageUrl, width, height, startingPosition, nightMode, isVeilOfNight) {
          Severity: Major
          Found in game/static/game/js/character.js - About 1 hr to fix

            Function scrollToShow has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            ocargo.Character.prototype.scrollToShow = function () {
                var dx = 150;
                var dy = 150;
            
                this.skipOutstandingAnimations();
            Severity: Minor
            Found in game/static/game/js/character.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

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

            ocargo.Character.prototype.turnRight = function (callback, scalingFactor) {
                var transformation = this._turnRightTransformation(FULL_TURN_ANGLE, scalingFactor);
            
                this._moveImage({
                    transform: transformation
            Severity: Major
            Found in game/static/game/js/character.js and 1 other location - About 4 hrs to fix
            game/static/game/js/character.js on lines 244..260

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

            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

            ocargo.Character.prototype.turnLeft = function (callback, scalingFactor) {
                var transformation = this._turnLeftTransformation(FULL_TURN_ANGLE, scalingFactor);
            
                this._moveImage({
                    transform: transformation
            Severity: Major
            Found in game/static/game/js/character.js and 1 other location - About 4 hrs to fix
            game/static/game/js/character.js on lines 262..277

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

            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

                function turnLeft(easing) {
                    var transformation = that._turnLeftTransformation(TURN_AROUND_TURN_ANGLE);
            
                    var duration = that._durationOf(TURN_AROUND_TURN_LEFT_DISTANCE);
            
            
            Severity: Major
            Found in game/static/game/js/character.js and 1 other location - About 2 hrs to fix
            game/static/game/js/character.js on lines 368..383

            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

                function turnRight(easing) {
                    var transformation = that._turnRightTransformation(TURN_AROUND_TURN_ANGLE);
            
                    var duration = that._durationOf(TURN_AROUND_TURN_RIGHT_DISTANCE);
            
            
            Severity: Major
            Found in game/static/game/js/character.js and 1 other location - About 2 hrs to fix
            game/static/game/js/character.js on lines 351..366

            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 (attemptedAction === "FORWARD") {
                    distance = CRASH_INTO_COW_MOVE_FORWARDS_DISTANCE;
                    var scaledDistance = distance / this.currentScale;
                    var transformation = "... t 0, " + (-scaledDistance);
                } else if (attemptedAction === "TURN_LEFT") {
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 55 mins to fix
            game/static/game/js/character.js on lines 499..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 54.

            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 (attemptedAction === "FORWARD") {
                    var transformation = "... t 0, " + (-CRASH_MOVE_FORWARD_DISTANCE);
                } else if (attemptedAction === "TURN_LEFT") {
                    var transformation = this._turnLeftTransformation(CRASH_TURN_ANGLE);
                } else if (attemptedAction === "TURN_RIGHT") {
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 55 mins to fix
            game/static/game/js/character.js on lines 520..528

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

            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

            ocargo.Character.prototype._animateCollisionNoFire = function () {
                var that = this;
                return function () {
                    that._animateCollision(false);
                }
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 45 mins to fix
            game/static/game/js/character.js on lines 462..468

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

            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

            ocargo.Character.prototype._animateCollisionWithFire = function () {
                var that = this;
            
                return function () {
                    that._animateCollision(true);
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 45 mins to fix
            game/static/game/js/character.js on lines 470..475

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

            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

            ocargo.Character.prototype._calculateInitialRotation = function (previousNode, startNode) {
                var nodeAngleRadians = ocargo.calculateNodeAngle(previousNode, startNode);
                var nodeAngleDegrees = nodeAngleRadians * (180 / Math.PI);
                return -nodeAngleDegrees; // Calculation is counterclockwise, transformations are clockwise
            };
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 35 mins to fix
            game/static/game/js/drawing.js on lines 207..211

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

                function scrollVertically(dy) {
                    if (closeToTheEdge(characterPositionY, dy, top, height)) {
                        element.scrollTop = centerPosition(characterPositionY, height);
                        return true;
                    }
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 30 mins to fix
            game/static/game/js/character.js on lines 161..167

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

            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

                var transformation = ocargo.Drawing.rotationTransformationAroundCentreOfGridSpace(
                    rotation,
                    position.currentNode.coordinate.x,
                    position.currentNode.coordinate.y);
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 30 mins to fix
            game/static/game/js/drawing.js on lines 438..442

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

            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

                function scrollHorizontally(dx) {
                    if (closeToTheEdge(characterPositionX, dx, left, width)) {
                        element.scrollLeft = centerPosition(characterPositionX, width);
                        return true;
                    }
            Severity: Minor
            Found in game/static/game/js/character.js and 1 other location - About 30 mins to fix
            game/static/game/js/character.js on lines 169..175

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

            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