GladysProject/Gladys

View on GitHub
front/src/routes/integration/all/zigbee2mqtt/discover-page/DiscoveredBox.jsx

Summary

Maintainability
F
3 days
Test Coverage

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

  render({ device = {}, deviceIndex, houses = [] }, { loading, saveError }) {
    const { features = [] } = device;
    const enableSaveButton = !device.created_at;
    const enableUpdateButton = device.updatable;
    const supportedDevice = features.findIndex(f => f.category !== DEVICE_FEATURE_CATEGORIES.BATTERY) >= 0;

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

                        <div class="form-group">
                          <label class="form-label" for={`room_${deviceIndex}`}>
                            <Text id="integration.zigbee2mqtt.roomLabel" />
                          </label>
                          <select onChange={this.updateRoom} class="form-control" id={`room_${deviceIndex}`}>
    front/src/routes/integration/all/broadlink/device-page/DeviceBox.jsx on lines 117..135

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

    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

      saveDevice = async () => {
        this.setState({
          loading: true
        });
        try {
    front/src/routes/integration/all/rtsp-camera/RtspCameraBox.jsx on lines 9..26
    front/src/routes/integration/all/zigbee2mqtt/device-page/Zigbee2mqttBox.jsx on lines 40..57

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

    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

                    {!supportedDevice && (
                      <div>
                        <div class="alert alert-warning">
                          <Text id="integration.zigbee2mqtt.discover.deviceNotHandled" />
                        </div>
    front/src/routes/integration/all/netatmo/NetatmoDeviceBox.jsx on lines 390..399

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

    const createGithubUrl = device => {
      const title = encodeURIComponent(`Zigbee2mqtt: Add device ${device.model}`);
      const body = encodeURIComponent(`\`\`\`\n${JSON.stringify(device, null, 2)}\n\`\`\``);
      return `${GITHUB_BASE_URL}?title=${title}&body=${body}`;
    };
    front/src/routes/integration/all/netatmo/NetatmoDeviceBox.jsx on lines 17..21
    front/src/routes/integration/all/philips-hue/device-page/FoundDevices.jsx on lines 13..17
    front/src/routes/integration/all/tp-link/device-page/FoundDevices.jsx on lines 13..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 87.

    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