FarmBot/Farmbot-Web-App

View on GitHub
frontend/sequences/sequence_editor_middle_active.tsx

Summary

Maintainability
F
5 days
Test Coverage

File sequence_editor_middle_active.tsx has 860 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from "react";
import { t } from "../i18next_wrapper";
import {
  ActiveMiddleProps, SequenceHeaderProps, SequenceBtnGroupProps,
  SequenceSettingProps, SequenceSettingsMenuProps, ActiveMiddleState,
Severity: Major
Found in frontend/sequences/sequence_editor_middle_active.tsx - About 2 days to fix

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

      render() {
        const { dispatch, sequence } = this.props;
        const { viewSequenceCeleryScript, view } = this.state;
        const variableData = this.props.resources.sequenceMetas[sequence.uuid] || {};
        const declarations = betterCompact(Object.values(variableData)
    Severity: Major
    Found in frontend/sequences/sequence_editor_middle_active.tsx - About 6 hrs to fix

      Function Description has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Description = (props: DescriptionProps) => {
        const sequenceDescription = props.sequence.body.description || "";
        const [description, setDescription] = React.useState(sequenceDescription);
        const [isEditing, setIsEditing] = React.useState(false);
        const [isProcessing, setIsProcessing] = React.useState(false);
      Severity: Major
      Found in frontend/sequences/sequence_editor_middle_active.tsx - About 2 hrs to fix

        Function SequencePublishMenu has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const SequencePublishMenu = (props: SequenceShareMenuProps) => {
          const { sequence } = props;
          const disabled = sequence.specialStatus !== SpecialStatus.SAVED;
          const [publishing, setPublishing] = React.useState(false);
          const [copyright, setCopyright] = React.useState(sequence.body.copyright || "");
        Severity: Major
        Found in frontend/sequences/sequence_editor_middle_active.tsx - About 2 hrs to fix

          Function ImportedBanner has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const ImportedBanner = (props: ImportedBannerProps) => {
            const versionId = props.sequence.body.sequence_version_id;
            const allIds = sortBy(props.sequence.body.sequence_versions);
            const latestId = last(allIds);
            const versionList = sequenceVersionList(allIds);
          Severity: Major
          Found in frontend/sequences/sequence_editor_middle_active.tsx - About 2 hrs to fix

            Function SequenceShareMenu has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const SequenceShareMenu = (props: SequenceShareMenuProps) => {
              const { sequence } = props;
              const disabled = sequence.specialStatus !== SpecialStatus.SAVED;
              const ids = sortBy(sequence.body.sequence_versions);
              const linkPath = Path.sequenceVersion(last(ids));
            Severity: Minor
            Found in frontend/sequences/sequence_editor_middle_active.tsx - About 1 hr to fix

              Function ImportedBanner has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              export const ImportedBanner = (props: ImportedBannerProps) => {
                const versionId = props.sequence.body.sequence_version_id;
                const allIds = sortBy(props.sequence.body.sequence_versions);
                const latestId = last(allIds);
                const versionList = sequenceVersionList(allIds);
              Severity: Minor
              Found in frontend/sequences/sequence_editor_middle_active.tsx - About 1 hr 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 AddCommandButton has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const AddCommandButton = (props: AddCommandButtonProps) => {
                const { index, dispatch, stepCount } = props;
                const getPositionClass = () => {
                  switch (index) {
                    case 0: return "first";
              Severity: Minor
              Found in frontend/sequences/sequence_editor_middle_active.tsx - About 1 hr to fix

                Function SequenceSettingsMenu has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  (props: SequenceSettingsMenuProps) => {
                    const { dispatch, getWebAppConfigValue } = props;
                    const commonProps = { dispatch, getWebAppConfigValue };
                    return <div className="sequence-settings-menu">
                      <SequenceSetting {...commonProps}
                Severity: Minor
                Found in frontend/sequences/sequence_editor_middle_active.tsx - About 1 hr to fix

                  Function render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    render() {
                      const { dispatch, sequence } = this.props;
                      const { viewSequenceCeleryScript, view } = this.state;
                      const variableData = this.props.resources.sequenceMetas[sequence.uuid] || {};
                      const declarations = betterCompact(Object.values(variableData)
                  Severity: Minor
                  Found in frontend/sequences/sequence_editor_middle_active.tsx - About 1 hr 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 SequenceBtnGroup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const SequenceBtnGroup = ({
                    dispatch,
                    sequence,
                    syncStatus,
                    resources,
                  Severity: Minor
                  Found in frontend/sequences/sequence_editor_middle_active.tsx - About 45 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

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

                  export const AddCommandButton = (props: AddCommandButtonProps) => {
                    const { index, dispatch, stepCount } = props;
                    const getPositionClass = () => {
                      switch (index) {
                        case 0: return "first";
                  Severity: Minor
                  Found in frontend/sequences/sequence_editor_middle_active.tsx - 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

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

                    (dispatch1: Function, sequence: TaggedSequence) =>
                      (index: number, key: string) => {
                        if (key.length > 0) {
                          dispatch1(function (dispatch2: Function) {
                            const dataXferObj = dispatch2(stepGet(key));
                  Severity: Minor
                  Found in frontend/sequences/sequence_editor_middle_active.tsx - 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 2 locations. Consider refactoring.
                  Open

                      <i className={"fa fa-trash fb-icon-button"}
                        title={t("delete sequence")}
                        onClick={deleteSequence({
                          sequenceUuid: sequence.uuid,
                          getWebAppConfigValue,
                  Severity: Major
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 1 other location - About 1 hr to fix
                  frontend/folders/component.tsx on lines 178..185

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

                  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

                    toggleSection = (key: keyof ActiveMiddleState) => () =>
                      this.setState({ ...this.state, [key]: !this.state[key] });
                  Severity: Major
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 4 other locations - About 50 mins to fix
                  frontend/curves/edit_curve.tsx on lines 99..100
                  frontend/farm_designer/move_to.tsx on lines 164..165
                  frontend/sequences/panel/preview.tsx on lines 40..41
                  frontend/tools/index.tsx on lines 159..160

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

                  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={`copy-item ${props.view == "local" ? "" : "selected"}`}
                            onClick={props.selectView("public")}>
                            <label>{t("public copy")}</label>
                            <FBSelect
                              key={props.selectedVersionId}
                  Severity: Minor
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 1 other location - About 45 mins to fix
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 769..782

                  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

                          <div className={`copy-item ${props.view == "local" ? "selected" : ""}`}
                            onClick={props.selectView("local")}>
                            <label>{t("your copy")}</label>
                            {forked
                              ? <Popover
                  Severity: Minor
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 1 other location - About 45 mins to fix
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 783..791

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

                                    <button className={"fb-button gray"}
                                      onClick={this.addVariable(variableData, declarations,
                                        VariableType.Location)}>
                                      {t("location")}
                                    </button>
                  Severity: Major
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 3 other locations - About 40 mins to fix
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 571..575
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 576..580
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 581..585

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

                                    <button className={"fb-button gray"}
                                      onClick={this.addVariable(variableData, declarations,
                                        VariableType.Resource)}>
                                      {t("resource")}
                                    </button>
                  Severity: Major
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 3 other locations - About 40 mins to fix
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 566..570
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 571..575
                  frontend/sequences/sequence_editor_middle_active.tsx 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 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 4 locations. Consider refactoring.
                  Open

                                    <button className={"fb-button gray"}
                                      onClick={this.addVariable(variableData, declarations,
                                        VariableType.Number)}>
                                      {t("number")}
                                    </button>
                  Severity: Major
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 3 other locations - About 40 mins to fix
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 566..570
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 576..580
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 581..585

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

                                    <button className={"fb-button gray"}
                                      onClick={this.addVariable(variableData, declarations,
                                        VariableType.Text)}>
                                      {t("text")}
                                    </button>
                  Severity: Major
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 3 other locations - About 40 mins to fix
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 566..570
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 571..575
                  frontend/sequences/sequence_editor_middle_active.tsx on lines 581..585

                  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

                    <a href={ExternalUrl.mitLicense} target={"_blank"} rel={"noreferrer"}>
                      {t("MIT License")}
                    </a>;
                  Severity: Minor
                  Found in frontend/sequences/sequence_editor_middle_active.tsx and 1 other location - About 30 mins to fix
                  frontend/wizard/step.tsx on lines 191..193

                  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