AugurProject/augur-ui

View on GitHub
src/modules/reporting/components/reporting-dispute-form/reporting-dispute-form.jsx

Summary

Maintainability
F
4 days
Test Coverage

File reporting-dispute-form.jsx has 621 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint jsx-a11y/label-has-for: 0 */

import React, { Component } from "react";
import PropTypes from "prop-types";
import classNames from "classnames";

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

      render() {
        const { market, stakeInfo, outcomes } = this.props;
        const s = this.state;
        const winner = (outcomes && outcomes.find(o => o.tentativeWinning)) || {};
        const disputeRound = market.disputeInfo && market.disputeInfo.disputeRound;

      Function validateScalar has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        validateScalar(value, humanName, min, max, tickSize, isInvalid) {
          const { stakeInfo, updateState } = this.props;
          const updatedValidations = { ...this.state.validations };
      
          if (value === "") {

        Function validateStake has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          validateStake(rawStakeObj) {
            const { updateState } = this.props;
            const updatedValidations = { ...this.state.validations };
            let completeStakeObj = rawStakeObj;
            const maxInfo = this.calculateMaxRep(this.state.selectedOutcome);

          Function setAccountDisputeData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            setAccountDisputeData(accountDisputeData) {
              const { stakeInfo, updateState } = this.props;
              if (stakeInfo && createBigNumber(stakeInfo.repValue).gt(ZERO)) {
                delete accountDisputeData.validations.stake;
              }

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

              validateSavedValues() {
                const { market, outcomes } = this.props;
                const {
                  validations,
                  selectedOutcome,

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

                checkStake(stakeValue, updatedValidations, maxRepObject) {
                  if (
                    stakeValue === "" ||
                    stakeValue == null ||
                    stakeValue === 0 ||

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

                  validateScalar(value, humanName, min, max, tickSize, isInvalid) {
                    const { stakeInfo, updateState } = this.props;
                    const updatedValidations = { ...this.state.validations };
                
                    if (value === "") {

                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

                              {s.validations.hasOwnProperty("stake") &&
                                s.validations.stake.length && (
                                  <span className={FormStyles["Form__error--even"]}>
                                    {InputErrorIcon}
                                    {s.validations.stake}
                src/modules/account/components/account-withdraw/account-withdraw.jsx on lines 292..298
                src/modules/account/components/account-withdraw/account-withdraw.jsx on lines 311..317

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

                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

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

                        case bnValue
                          .minus(bnMinPrice)
                          .mod(bnTickSize)
                          .gt("0"):
                          updatedValidations.err = `The ${humanName} field must be a multiple of ${tickSize}.`;
                src/modules/reporting/components/reporting-report-form/reporting-report-form.jsx on lines 154..159

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

                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={Styles.ReportingReport__malformed_msg}>
                            <span>
                              WARNING: The tentative outcome for this market is currently
                              MALFORMED.
                            </span>
                src/modules/account/components/account-withdraw/account-withdraw.jsx on lines 237..246

                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

                Identical blocks of code found in 3 locations. Consider refactoring.
                Open

                        case valueValue > maxValue || valueValue < minValue:
                          updatedValidations.err = `Please enter a ${humanName} between ${min} and ${max}.`;
                          break;
                src/modules/forking/components/migrate-rep-form/migrate-rep-form.jsx on lines 144..146
                src/modules/reporting/components/reporting-report-form/reporting-report-form.jsx on lines 151..153

                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