theforeman/foreman_fog_proxmox

View on GitHub

Showing 185 of 185 total issues

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

        <InputField
          name={hw?.swap?.name}
          label={__('Swap (MB)')}
          type="text"
          value={hw?.swap?.value}
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

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

      <InputField
        name={network?.rate?.name}
        label={__('Rate limit')}
        type="text"
        value={network?.rate?.value}
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

Method host_interfaces_attrs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def host_interfaces_attrs(host)
      host.interfaces.select(&:physical?).each.with_index.reduce({}) do |hash, (nic, index)|
        set_nic_identifier(nic, index)
        set_container_interface_name(host, nic, index) if container?(host)
        ForemanFogProxmox::HashCollection.remove_empty_values(nic.compute_attributes)
Severity: Minor
Found in app/models/foreman_fog_proxmox/proxmox_interfaces.rb - 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

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

        <InputField
          name={hw?.cpulimit?.name}
          label={__('CPU limit')}
          type="number"
          value={hw?.cpulimit?.value}
Severity: Major
Found in webpack/components/ProxmoxServer/ProxmoxServerHardware.js and 23 other locations - About 1 hr to fix
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

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

        <InputField
          name={hw?.memory?.name}
          label={__('Memory (MB)')}
          type="text"
          value={hw?.memory?.value}
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

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

        <InputField
          name={hw?.cores?.name}
          label={__('Cores')}
          type="number"
          value={hw?.cores?.value}
Severity: Major
Found in webpack/components/ProxmoxServer/ProxmoxServerHardware.js and 23 other locations - About 1 hr to fix
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

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

        <InputField
          name={rootfs?.size?.name}
          label={__('Size (GB)')}
          type="number"
          value={rootfs?.size?.value}
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

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

      <InputField
        name={network?.rate?.name}
        label={__('Rate limit')}
        type="text"
        value={network?.rate?.value}
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

Function NetworkInterface has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const NetworkInterface = ({
  id,
  networks,
  bridges,
  data,
Severity: Minor
Found in webpack/components/ProxmoxServer/components/NetworkInterface.js - 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

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

      <InputField
        name={network?.tag?.name}
        label={__('VLAN Tag')}
        type="text"
        value={network?.tag?.value}
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/HardDisk.js on lines 121..127
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

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

      <InputField
        name={hdd?.size?.name}
        label={__('Size (GB)')}
        type="number"
        value={hdd?.size?.value}
Severity: Major
Found in webpack/components/ProxmoxServer/components/HardDisk.js and 23 other locations - About 1 hr to fix
webpack/components/GeneralTabContent.js on lines 77..83
webpack/components/ProxmoxContainer/MountPoint.js on lines 46..52
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 33..39
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 40..46
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 47..53
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 58..64
webpack/components/ProxmoxContainer/ProxmoxContainerHardware.js on lines 65..71
webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js on lines 125..131
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 122..128
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 145..151
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 152..158
webpack/components/ProxmoxContainer/components/NetworkInterface.js on lines 159..165
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 104..110
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 111..117
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 118..124
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 125..131
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 132..138
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 170..176
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 177..183
webpack/components/ProxmoxServer/ProxmoxServerHardware.js on lines 184..190
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 92..98
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 99..105
webpack/components/ProxmoxServer/components/NetworkInterface.js on lines 106..112

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

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

    (event, initialData = null, isPreExisting = false) => {
      if (event) event.preventDefault();
      if (!initialData && cdRom) return;

      const deviceInfo = initialData
Severity: Minor
Found in webpack/components/ProxmoxServer/ProxmoxServerStorage.js - About 1 hr to fix

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

    function getIndex(item) {
      var index_id = $(item).attr('id');
      var pattern = /(host_compute_attributes_volumes_attributes_||compute_attribute_vm_attrs_volumes_attributes_)(\d+)[_](.*)/i;
      pattern_a = pattern.exec(index_id);
      var index = pattern_a[2];
    app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js on lines 26..32

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

    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

    function getIndex(item) {
      var index_id = $(item).attr('id');
      var pattern = /(host_compute_attributes_volumes_attributes_||compute_attribute_vm_attrs_volumes_attributes_)(\d+)[_](.*)/i;
      pattern_a = pattern.exec(index_id);
      var index = pattern_a[2];
    app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js on lines 18..24

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

    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

    Function handleChange has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const handleChange = e => {
        const { name, type, checked, value: targetValue } = e.target;
        let value;
        if (type === 'checkbox') {
          value = checked ? '1' : '0';
    Severity: Minor
    Found in webpack/components/ProxmoxServer/components/NetworkInterface.js - About 1 hr to fix

      Method proxmox_cpus_map has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def proxmox_cpus_map
          [OpenStruct.new(id: '486', name: '486'),
           OpenStruct.new(id: 'athlon', name: 'athlon'),
           OpenStruct.new(id: 'core2duo', name: 'core2duo'),
           OpenStruct.new(id: 'coreduo', name: 'coreduo'),
      Severity: Minor
      Found in app/helpers/proxmox_compute_selectors_helper.rb - About 1 hr to fix

        Method new_typed_vm has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def new_typed_vm(new_attr, type)
              convert_config_attributes(new_attr) if new_attr.key?(:config_attributes)
              node_id = new_attr['node_id']
              node = node_id ? client.nodes.get(node_id) : default_node
              new_attr_type = new_attr['type']
        Severity: Minor
        Found in app/models/foreman_fog_proxmox/proxmox_vm_new.rb - 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 updateOptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function updateOptions(options_path, start_options_id, end_options_id, start_second_options_id, end_second_options_id, option_id, node_id, second_id) {
          
          var select_ids = selectIds(start_options_id, end_options_id);
          var select_second_ids;
          if ( start_second_options_id != undefined && end_second_options_id != undefined) {
        Severity: Minor
        Found in app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js - 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

        Method password_proxmox_f has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def password_proxmox_f(f, attr, options = {})
            unset_button = options.delete(:unset)
            value = f.object[attr] if options.delete(:keep_value)
            password_field_tag(:fakepassword, value, :style => 'display: none', :autocomplete => 'new-password-fake') +
              field(f, attr, options) do
        Severity: Minor
        Found in app/helpers/proxmox_form_helper.rb - 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

        Method add_or_delete_typed_interface has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def add_or_delete_typed_interface(interface_attributes, interfaces_to_delete, interfaces_to_add, type)
            logger.debug("add_or_delete_typed_interface(#{type}): interface_attributes=#{interface_attributes}")
            ForemanFogProxmox::HashCollection.remove_empty_values(interface_attributes)
            if interface_attributes['compute_attributes']
              ForemanFogProxmox::HashCollection.remove_empty_values(interface_attributes['compute_attributes'])
        Severity: Minor
        Found in app/helpers/proxmox_vm_interfaces_helper.rb - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language