AugurProject/augur-ui

View on GitHub
src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx

Summary

Maintainability
F
1 wk
Test Coverage

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

  render() {
    const { newMarket, keyPressed } = this.props;
    const s = this.state;
    const cleanedOutcomes = newMarket.outcomes.filter(
      outcome => outcome !== ""

    File create-market-form-outcome.jsx has 580 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint jsx-a11y/label-has-for: 0 */
    /* eslint react/no-array-index-key: 0 */
    
    import React, { Component } from "react";
    import PropTypes from "prop-types";

      Function validateScalarNum has 137 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        validateScalarNum(rawValue, type, limitDigits) {
          const { isValid, newMarket, updateNewMarket } = this.props;
          const { currentStep } = newMarket;
          const { scalarType } = this.state;
      
      

        Function validateScalarNum has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          validateScalarNum(rawValue, type, limitDigits) {
            const { isValid, newMarket, updateNewMarket } = this.props;
            const { currentStep } = newMarket;
            const { scalarType } = this.state;
        
        

        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 validateType has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          validateType(value) {
            const { isValid, newMarket, updateNewMarket } = this.props;
            const updatedMarket = { ...newMarket };
            const validations = updatedMarket.validations[newMarket.currentStep];
        
        

          Function validateType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            validateType(value) {
              const { isValid, newMarket, updateNewMarket } = this.props;
              const updatedMarket = { ...newMarket };
              const validations = updatedMarket.validations[newMarket.currentStep];
          
          

          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 validateOutcomes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            validateOutcomes(value, index) {
              const { isValid, newMarket, updateNewMarket } = this.props;
              const { currentStep } = newMarket;
          
              const updatedMarket = { ...newMarket };

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

              constructor(props) {
                super(props);
                this.state = {
                  // marketType: false,
                  outcomeFieldCount: CreateMarketOutcome.calculateOutcomeFieldCount(

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

                            <div>
                              <label htmlFor="cm__input--max">
                                <span>&nbsp;</span>
                              </label>
                              <input
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 479..511

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

              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 htmlFor="cm__input--min">
                                <span>Range Values</span>
                              </label>
                              <input
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 512..544

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

              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

                  switch (true) {
                    case scalarSmallNum === "":
                      updatedMarket.validations[currentStep].scalarSmallNum =
                        "This field is required.";
                      break;
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 236..261

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

              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

                    switch (true) {
                      case scalarBigNum === "":
                        updatedMarket.validations[currentStep].scalarBigNum =
                          "This field is required.";
                        break;
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 207..232

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

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

                          <li>
                            <button
                              className={classNames({
                                [`${StylesForm.active}`]: newMarket.type === YES_NO
                              })}
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 393..403
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 404..414
              src/modules/create-market/components/create-market-form-resolution/create-market-form-resolution.jsx on lines 112..123
              src/modules/create-market/components/create-market-form-resolution/create-market-form-resolution.jsx on lines 174..188

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

                          <li>
                            <button
                              className={classNames({
                                [`${StylesForm.active}`]: newMarket.type === CATEGORICAL
                              })}
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 382..392
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 404..414
              src/modules/create-market/components/create-market-form-resolution/create-market-form-resolution.jsx on lines 112..123
              src/modules/create-market/components/create-market-form-resolution/create-market-form-resolution.jsx on lines 174..188

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

                          <li>
                            <button
                              className={classNames({
                                [`${StylesForm.active}`]: newMarket.type === SCALAR
                              })}
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 382..392
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 393..403
              src/modules/create-market/components/create-market-form-resolution/create-market-form-resolution.jsx on lines 112..123
              src/modules/create-market/components/create-market-form-resolution/create-market-form-resolution.jsx on lines 174..188

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

                static propTypes = {
                  isMobileSmall: PropTypes.bool.isRequired,
                  newMarket: PropTypes.object.isRequired,
                  isValid: PropTypes.func.isRequired,
                  keyPressed: PropTypes.func.isRequired,
              src/modules/create-market/components/create-market-form-resolution/create-market-form-resolution.jsx on lines 19..25
              src/modules/modal/components/modal-market-review.jsx on lines 10..16
              src/modules/modal/components/modal-migrate-market.jsx on lines 9..15

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

                              {validation.tickSize && (
                                <span className={StylesForm.CreateMarketForm__error_tick}>
                                  {InputErrorIcon}
                                  {validation.tickSize}
                                </span>
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 421..426
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 590..595

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

                              {validation.scalarDenomination && (
                                <span className={StylesForm.CreateMarketForm__error_tick}>
                                  {InputErrorIcon}
                                  {validation.scalarDenomination}
                                </span>
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 421..426
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 615..620

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

                            {validation.outcomes && (
                              <span className={StylesForm.CreateMarketForm__error}>
                                {InputErrorIcon}
                                {validation.outcomes}
                              </span>
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 590..595
              src/modules/create-market/components/create-market-form-outcome/create-market-form-outcome.jsx on lines 615..620

              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