hammackj/risu

View on GitHub

Showing 178 of 178 total issues

Method render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def render output
                output.text Report.classification.upcase, :align => :center
                output.text "\n"

                output.font_size(22) { output.text Report.title, :align => :center }
Severity: Minor
Found in lib/risu/templates/ms_update_summary.rb - 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

Method anon_smb_count has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def anon_smb_count
                count = 0
                begin
                    anon_smb_query().each do |finding|
                        host = Host.find_by_id(finding.host_id)
Severity: Minor
Found in lib/risu/base/shares_template_helper.rb - 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

Method other_os_graph_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

                def other_os_graph_text
                    text = "This graph shows the percentage of the different Non-Windows based operating systems " +
                    "found on the #{Report.title} network.\n\n"

                    linux = Host.os_linux.to_a.size
Severity: Minor
Found in lib/risu/models/host.rb - 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

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

                @output.table([headers] + data, :header => true, :width => output.bounds.width) do
                    row(0).style(:font_style => :bold, :background_color => 'cccccc')
                    cells.borders = [:top, :bottom, :left, :right]
Severity: Minor
Found in lib/risu/base/malware_template_helper.rb and 1 other location - About 25 mins to fix
lib/risu/base/host_template_helper.rb on lines 50..52

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

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 shares_section_has_findings? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

            def shares_section_has_findings?
                poor_count = 0

                anon_ftp_text = ""
                anon_smb_text = ""
Severity: Minor
Found in lib/risu/base/shares_template_helper.rb - 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

Method fix_ips has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

                def fix_ips
                    @hosts = Host.all

                    @hosts.each do |host|
                        if host.ip == nil
Severity: Minor
Found in lib/risu/parsers/nessus/nessus_document.rb - 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

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

                @output.table([headers] + data, :header => true, :width => output.bounds.width) do
                    row(0).style(:font_style => :bold, :background_color => 'cccccc')
                    cells.borders = [:top, :bottom, :left, :right]
Severity: Minor
Found in lib/risu/base/host_template_helper.rb and 1 other location - About 25 mins to fix
lib/risu/base/malware_template_helper.rb on lines 59..61

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

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

                            hosts.each do |host|
                                h = Host.find_by_id(host.host_id)
                                host_string = "#{h.name}"
                                host_string << " (#{h.fqdn})" if h.fqdn != nil
                                hostlist << host_string
Severity: Minor
Found in lib/risu/templates/notable_detailed.rb and 1 other location - About 25 mins to fix
lib/risu/templates/technical_findings.rb on lines 59..63

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

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

                        hosts.each do |host|
                            ho = Host.find_by_id(host.host_id)
                            host_string = "#{ho.name}"
                            host_string << " (#{ho.fqdn})" if ho.fqdn != nil
                            hostlist << host_string
Severity: Minor
Found in lib/risu/templates/technical_findings.rb and 1 other location - About 25 mins to fix
lib/risu/templates/notable_detailed.rb on lines 83..87

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

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

    module Parsers
        module Nessus
            module PostProcess
                class LibreOfficePatchRollup < Risu::Base::PostProcessBase

Severity: Major
Found in lib/risu/parsers/nessus/postprocess/libreoffice.rb and 5 other locations - About 25 mins to fix
lib/risu/parsers/nessus/postprocess/blackberry_enterprise_server.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/ca_brightstor_arcserve.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/foxit_phantom_pdf.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/real_player.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/symantec_endpoint.rb on lines 23..46

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

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

    module Parsers
        module Nessus
            module PostProcess
                class SymantecEndpointPatchRollup < Risu::Base::PostProcessBase

Severity: Major
Found in lib/risu/parsers/nessus/postprocess/symantec_endpoint.rb and 5 other locations - About 25 mins to fix
lib/risu/parsers/nessus/postprocess/blackberry_enterprise_server.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/ca_brightstor_arcserve.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/foxit_phantom_pdf.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/libreoffice.rb on lines 23..47
lib/risu/parsers/nessus/postprocess/real_player.rb on lines 23..46

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

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

    module Parsers
        module Nessus
            module PostProcess
                class BlackBerryEnterpriseServerRollups < Risu::Base::PostProcessBase

lib/risu/parsers/nessus/postprocess/ca_brightstor_arcserve.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/foxit_phantom_pdf.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/libreoffice.rb on lines 23..47
lib/risu/parsers/nessus/postprocess/real_player.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/symantec_endpoint.rb on lines 23..46

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

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

    module Parsers
        module Nessus
            module PostProcess
                class RealPlayerPatchRollup < Risu::Base::PostProcessBase

Severity: Major
Found in lib/risu/parsers/nessus/postprocess/real_player.rb and 5 other locations - About 25 mins to fix
lib/risu/parsers/nessus/postprocess/blackberry_enterprise_server.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/ca_brightstor_arcserve.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/foxit_phantom_pdf.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/libreoffice.rb on lines 23..47
lib/risu/parsers/nessus/postprocess/symantec_endpoint.rb on lines 23..46

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

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

    module Parsers
        module Nessus
            module PostProcess
                class FoxitPhantomPDFPatchRollup < Risu::Base::PostProcessBase

Severity: Major
Found in lib/risu/parsers/nessus/postprocess/foxit_phantom_pdf.rb and 5 other locations - About 25 mins to fix
lib/risu/parsers/nessus/postprocess/blackberry_enterprise_server.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/ca_brightstor_arcserve.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/libreoffice.rb on lines 23..47
lib/risu/parsers/nessus/postprocess/real_player.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/symantec_endpoint.rb on lines 23..46

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

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

    module Parsers
        module Nessus
            module PostProcess
                class CABrightstorArcServe < Risu::Base::PostProcessBase

Severity: Major
Found in lib/risu/parsers/nessus/postprocess/ca_brightstor_arcserve.rb and 5 other locations - About 25 mins to fix
lib/risu/parsers/nessus/postprocess/blackberry_enterprise_server.rb on lines 23..45
lib/risu/parsers/nessus/postprocess/foxit_phantom_pdf.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/libreoffice.rb on lines 23..47
lib/risu/parsers/nessus/postprocess/real_player.rb on lines 23..46
lib/risu/parsers/nessus/postprocess/symantec_endpoint.rb on lines 23..46

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

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

                begin
                    p = Plugin.where(:id => @info[:plugin_ids]).where.not(:cvss_base_score => nil).order(:cvss_base_score).last
                    unless p.nil?
                        plugin.cvss_base_score = p.cvss_base_score
                        plugin.cvss_vector = p.cvss_vector
Severity: Minor
Found in lib/risu/base/post_process_base.rb and 1 other location - About 25 mins to fix
lib/risu/base/post_process_base.rb on lines 104..108

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

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

                begin
                    p = Plugin.where(:id => @info[:plugin_ids]).where.not(:cvss_temporal_score => nil).order(:cvss_temporal_score).last
                    unless p.nil?
                        plugin.cvss_temporal_score = p.cvss_temporal_score
                        plugin.cvss_temporal_vector = p.cvss_temporal_vector
Severity: Minor
Found in lib/risu/base/post_process_base.rb and 1 other location - About 25 mins to fix
lib/risu/base/post_process_base.rb on lines 96..100

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

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

                def critical_risks_by_host(limit=10)
                    #select("items.*").select("count(*) as count_all").joins(:host).where("plugin_id != 1").where(:severity => 4).group(:host_id).order("count_all DESC").limit(limit)
                    Item.joins(:host).where.not(plugin_id: 1).where(:severity => 4).where(:rollup_finding => false).group(:host_id).order(Arel.sql('COUNT(*) DESC')).limit(limit)
Severity: Minor
Found in lib/risu/models/item.rb and 3 other locations - About 20 mins to fix
lib/risu/models/item.rb on lines 230..233
lib/risu/models/item.rb on lines 241..243
lib/risu/models/item.rb on lines 251..253

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

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

                def high_risks_by_host(limit=10)
                    #select("items.*").select("count(*) as count_all").joins(:host).where("plugin_id != 1").where(:severity => 3).group(:host_id).order("count_all DESC").limit(limit)

                    Item.joins(:host).where.not(plugin_id: 1).where(:severity => 3).where(:rollup_finding => false).group(:host_id).order(Arel.sql('COUNT(*) DESC')).limit(limit)
Severity: Minor
Found in lib/risu/models/item.rb and 3 other locations - About 20 mins to fix
lib/risu/models/item.rb on lines 220..222
lib/risu/models/item.rb on lines 241..243
lib/risu/models/item.rb on lines 251..253

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

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

                def low_risks_by_host(limit=10)
                    #select("items.*").select("count(*) as count_all").joins(:host).where("plugin_id != 1").where(:severity => 1).group(:host_id).order("count_all DESC").limit(limit)
                    Item.joins(:host).where.not(plugin_id: 1).where(:severity => 1).where(:rollup_finding => false).group(:host_id).order(Arel.sql('COUNT(*) DESC')).limit(limit)
Severity: Minor
Found in lib/risu/models/item.rb and 3 other locations - About 20 mins to fix
lib/risu/models/item.rb on lines 220..222
lib/risu/models/item.rb on lines 230..233
lib/risu/models/item.rb on lines 241..243

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

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

Severity
Category
Status
Source
Language