unclesp1d3r/CipherSwarm

View on GitHub

Showing 475 of 475 total issues

MaskCalculationMethods#self.calculate_mask_candidates calls 'charset_counts[composite_char]' 2 times
Open

        elsif charset_counts[composite_char]
          variable_candidates *= BigDecimal(charset_counts[composite_char].to_s)
Severity: Minor
Found in lib/mask_calculation_methods.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Avoid too many return statements within this method.
Open

      return nil if patch_match.empty?
Severity: Major
Found in app/models/cracker_binary.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return tasks.create(attack: attack, start_date: Time.zone.now) if meets_performance_threshold?(attack.hash_mode)
Severity: Major
Found in app/models/agent.rb - About 30 mins to fix

Render path contains parameter value
Open

      <%= render Railsboot::ButtonComponent.new(tag: "a", href: url_for([:download, @resource]), size: "sm") do %>

When a call to render uses a dynamically generated path, template name, file name, or action, there is the possibility that a user can access templates that should be restricted. The issue may be worse if those templates execute code or modify the database.

This warning is shown whenever the path to be rendered is not a static string or symbol.

These warnings are often false positives, however, because it can be difficult to manipulate Rails' assumptions about paths to perform malicious behavior. Reports of dynamic render paths should be checked carefully to see if they can actually be manipulated maliciously by the user.

Avoid too many return statements within this method.
Open

      return nil if latest.nil?
Severity: Major
Found in app/models/cracker_binary.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return pending_task if pending_task
Severity: Major
Found in app/models/agent.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return head :gone if @task.paused?
Severity: Major
Found in app/controllers/api/v1/client/tasks_controller.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return
Severity: Major
Found in app/controllers/api/v1/client/crackers_controller.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

    return unless task.completed?
Severity: Major
Found in app/controllers/api/v1/client/tasks_controller.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return patch_match.first if patch_match.first.patch_version > sem_version.patch
Severity: Major
Found in app/models/cracker_binary.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

      return head :no_content
Severity: Major
Found in app/controllers/api/v1/client/tasks_controller.rb - About 30 mins to fix

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

  def sidebar_link(name, path, icon)
    class_name = current_page?(path) ? "active" : ""
    content_tag :li, class: "nav-item" do
      link_to path, class: "nav-link #{class_name}" do
        if icon.nil?
Severity: Minor
Found in app/helpers/nav_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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(builder, attribute_name, column, input_type, options = {}) # rubocop:disable Metrics/ParameterLists
    raise ArgumentError, "EnumInput requires an enum column." unless column.is_a? ActiveRecord::Enum::EnumType

    # Enum's are only required if we do not allow nil values
    inclusion_validator = builder.object.class.validators_on(attribute_name).find { |v| v.kind == :inclusion }
Severity: Minor
Found in app/inputs/EnumInput.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    respond_to do |format|
      if @attack.update(attack_params)
        @attack.abandon! if @attack.can_abandon?
        format.html { redirect_to campaigns_path(@attack.campaign), notice: "Attack was successfully updated." }
Severity: Minor
Found in app/controllers/attacks_controller.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

CalculateMaskComplexityJob#perform doesn't depend on instance state (maybe move it to another class?)
Open

  def perform(mask_list_id)

A Utility Function is any instance method that has no dependency on the state of the instance.

CalculateMaskComplexityJob#perform performs a nil-check
Open

    return if mask_list.nil? || mask_list.file.nil? || mask_list.complexity_value != 0

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

UpdateStatusJob#check_agents_online_status doesn't depend on instance state (maybe move it to another class?)
Open

  def check_agents_online_status
Severity: Minor
Found in app/jobs/update_status_job.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

UpdateStatusJob#remove_finished_tasks_status doesn't depend on instance state (maybe move it to another class?)
Open

  def remove_finished_tasks_status
Severity: Minor
Found in app/jobs/update_status_job.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

UpdateStatusJob#pause_lower_priority_campaigns doesn't depend on instance state (maybe move it to another class?)
Open

  def pause_lower_priority_campaigns
Severity: Minor
Found in app/jobs/update_status_job.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

ApplicationHelper#current_url doesn't depend on instance state (maybe move it to another class?)
Open

  def current_url(request)
Severity: Minor
Found in app/helpers/application_helper.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

Severity
Category
Status
Source
Language