GladysProject/Gladys

View on GitHub
front/src/components/device/UpdateDeviceFeature.jsx

Summary

Maintainability
F
5 days
Test Coverage

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

  render({ feature, featureIndex, canEditCategory, device, ...props }) {
    const allowModifyCategory =
      canEditCategory && canEditCategory(device, feature) && DEVICE_FEATURE_COMPATIBLE_CATEGORY[feature.type];

    return (
Severity: Major
Found in front/src/components/device/UpdateDeviceFeature.jsx - About 6 hrs to fix

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

                    <Localizer>
                      <select
                        id={`unit_${featureIndex}`}
                        type="text"
                        value={feature.category}
    Severity: Major
    Found in front/src/components/device/UpdateDeviceFeature.jsx and 1 other location - About 7 hrs to fix
    front/src/components/device/UpdateDeviceFeature.jsx on lines 107..124

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

    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

                    <Localizer>
                      <select
                        id={`unit_${featureIndex}`}
                        type="text"
                        value={feature.unit}
    Severity: Major
    Found in front/src/components/device/UpdateDeviceFeature.jsx and 1 other location - About 7 hrs to fix
    front/src/components/device/UpdateDeviceFeature.jsx on lines 65..82

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

    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

                {props.allowModifyFeatures && (
                  <div class="form-group">
                    <label class="form-label" for={`max_${featureIndex}`}>
                      <Text id="editDeviceForm.maxLabel" />
                    </label>
    Severity: Major
    Found in front/src/components/device/UpdateDeviceFeature.jsx and 2 other locations - About 6 hrs to fix
    front/src/components/device/UpdateDeviceFeature.jsx on lines 85..101
    front/src/components/device/UpdateDeviceFeature.jsx on lines 127..143

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

    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

                {props.allowModifyFeatures && (
                  <div class="form-group">
                    <label class="form-label" for={`externalid_${featureIndex}`}>
                      <Text id="editDeviceForm.externalIdLabel" />
                    </label>
    Severity: Major
    Found in front/src/components/device/UpdateDeviceFeature.jsx and 2 other locations - About 6 hrs to fix
    front/src/components/device/UpdateDeviceFeature.jsx on lines 127..143
    front/src/components/device/UpdateDeviceFeature.jsx on lines 144..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 161.

    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

                {props.allowModifyFeatures && (
                  <div class="form-group">
                    <label class="form-label" for={`min_${featureIndex}`}>
                      <Text id="editDeviceForm.minLabel" />
                    </label>
    Severity: Major
    Found in front/src/components/device/UpdateDeviceFeature.jsx and 2 other locations - About 6 hrs to fix
    front/src/components/device/UpdateDeviceFeature.jsx on lines 85..101
    front/src/components/device/UpdateDeviceFeature.jsx on lines 144..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 161.

    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 class="card-header">
                <i class={`mr-2 fe fe-${get(DeviceFeatureCategoriesIcon, `${feature.category}.${feature.type}`)}`} />
                <Text id={`deviceFeatureCategory.${feature.category}.${feature.type}`} />
              </div>
    Severity: Major
    Found in front/src/components/device/UpdateDeviceFeature.jsx and 1 other location - About 3 hrs to fix
    front/src/routes/integration/all/mqtt/device-page/setup/Feature.jsx on lines 14..17

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

    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

                {props.allowModifyFeatures && (
                  <div class="form-group">
                    <button onClick={props.deleteFeature} class="btn btn-outline-danger">
                      <Text id="editDeviceForm.deleteLabel" />
                    </button>
    Severity: Major
    Found in front/src/components/device/UpdateDeviceFeature.jsx and 1 other location - About 1 hr to fix
    front/src/routes/map/NewArea.jsx on lines 118..124

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

    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