AppStateESS/homestead

View on GitHub
javascript/CheckOut/CheckOut.jsx

Summary

Maintainability
F
4 days
Test Coverage

File CheckOut.jsx has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import ReactDOM from 'react-dom';
import $ from 'jquery';
import PropTypes from 'prop-types';

Severity: Major
Found in javascript/CheckOut/CheckOut.jsx - About 1 day to fix

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

    errorFree() {
        var all_clear = true;
        var errors = [];
        let resident_selected = false;

Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx - 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 render has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render() {
        var alert = null;
        var residentClass = 'col-sm-3 ' + ($.inArray('resident', this.state.error) !== -1 ? 'checkout-error-border' : null);
        var noteClass = 'form-control ' + ($.inArray('note', this.state.error) !== -1 ? 'checkout-error-border' : null);
        if (this.state.error.length) {
Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx - About 1 hr to fix

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

    errorFree() {
        var all_clear = true;
        var errors = [];
        let resident_selected = false;

Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx - About 1 hr to fix

Function render has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render() {
        var codeAlertDiv = <div></div>;
        if (this.state.codeAlert) {
            codeAlertDiv = <div className="alert alert-warning"><strong>Note:</strong> This keycode does not match the checkin key code: {this.props.previousKeyCode}</div>;
        }
Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx - About 1 hr to fix

Function render has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    render() {
        var residentList = '';
        if (this.props.residents !== undefined) {
            this.props.residents.map(function(val){
                residentList = residentList.length ? residentList + ', ' + val.name : val.name;
Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx - About 1 hr to fix

Avoid too many return statements within this function.
Open

        return true;
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx - About 30 mins to fix

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

    isReadyToPost(){
        if (this.state.keyReturned === null) {
            return false;
        }
        if (this.state.keyReturned && this.state.keyCode === null) {
Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx - 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 3 locations. Consider refactoring.
Open

        if (this.state.side === null || this.state.side.length === 0) {
            errors.push('side');
            all_clear = false;
        } else {
            var sideError = $.inArray('side', errors);
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 2 other locations - About 3 hrs to fix
javascript/CheckOut/CheckOut.jsx on lines 288..296
javascript/CheckOut/CheckOut.jsx on lines 322..330

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

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

        if (this.state.damage_type === null || this.state.damage_type.length === 0) {
            errors.push('category');
            all_clear = false;
        } else {
            var catError = $.inArray('category', errors);
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 2 other locations - About 3 hrs to fix
javascript/CheckOut/CheckOut.jsx on lines 312..320
javascript/CheckOut/CheckOut.jsx on lines 322..330

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

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

        if (this.state.note === null || this.state.note.length === 0) {
            errors.push('note');
            all_clear = false;
        } else {
            var noteError = $.inArray('note', errors);
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 2 other locations - About 3 hrs to fix
javascript/CheckOut/CheckOut.jsx on lines 288..296
javascript/CheckOut/CheckOut.jsx on lines 312..320

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

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

                <div className="radio">
                    <label>
                        <input onChange={this.handleChange} type="radio" name="properCheckout" value="1"/>{' '}Proper Checkout
                    </label>
                </div>
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 1 other location - About 1 hr to fix
javascript/CheckOut/CheckOut.jsx on lines 576..580

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

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

                <div className="radio">
                    <label>
                        <input onChange={this.handleChange} type="radio"  name="properCheckout" value="0"/>{' '}Improper Checkout
                    </label>
                </div>
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 1 other location - About 1 hr to fix
javascript/CheckOut/CheckOut.jsx on lines 571..575

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

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

                        <div>
                            <label>
                                <input name="keyReturned" onChange={this.keyTurnIn} type="radio" value='false'/>{' '} Key not returned
                            </label>
                        </div>
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 1 other location - About 1 hr to fix
javascript/CheckOut/CheckOut.jsx on lines 162..166

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

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

                        <div>
                            <label>
                                <input name="keyReturned" onChange={this.keyTurnIn} type="radio" value='true'/>{' '} Key returned
                            </label>
                        </div>
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 1 other location - About 1 hr to fix
javascript/CheckOut/CheckOut.jsx on lines 167..171

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

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

                <ExistingDamages responsible={this.state.responsible} existingDamage={this.state.existingDamage} damageTypes={this.state.damageTypes}/>
Severity: Major
Found in javascript/CheckOut/CheckOut.jsx and 2 other locations - About 50 mins to fix
javascript/AssignByFloor/AssignByFloor.jsx on lines 227..227
javascript/StudentAddRoomDamages/roomDamage.jsx on lines 303..303

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

                                    <DamageTypeSelect damageTypes={this.props.damageTypes} onChange={this.categorySelected} error={this.state.error}/>
Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx and 1 other location - About 40 mins to fix
javascript/AssignByFloor/AssignByFloor.jsx on lines 386..386

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

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.state.damageOptions[category].map(function(optValue, key){ return (
                    <option key={key} value={optValue.id}>{optValue.description}</option>
                    ); })}
Severity: Minor
Found in javascript/CheckOut/CheckOut.jsx and 1 other location - About 35 mins to fix
javascript/AssignByFloor/AssignByFloor.jsx on lines 102..104

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

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