3scale/porta

View on GitHub
lib/gitlab/testing/request_blocker_middleware.rb

Summary

Maintainability
A
0 mins
Test Coverage

Gitlab::Testing::RequestBlockerMiddleware declares the class variable '@@slow_requests'
Open

      @@slow_requests = Concurrent::AtomicBoolean.new(false)

      # Returns the number of requests the server is currently processing.
      def self.num_active_requests
        @@num_active_requests.value

Class variables form part of the global runtime state, and as such make it easy for one part of the system to accidentally or inadvertently depend on another part of the system. So the system becomes more prone to problems where changing something over here breaks something over there. In particular, class variables can make it hard to set up tests (because the context of the test includes all global state).

For a detailed explanation, check out this article

Example

Given

class Dummy
  @@class_variable = :whatever
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Dummy declares the class variable @@class_variable (ClassVariable)

Getting rid of the smell

You can use class-instance variable to mitigate the problem (as also suggested in the linked article above):

class Dummy
  @class_variable = :whatever
end

Gitlab::Testing::RequestBlockerMiddleware declares the class variable '@@block_requests'
Open

      @@block_requests = Concurrent::AtomicBoolean.new(false)
      @@slow_requests = Concurrent::AtomicBoolean.new(false)

      # Returns the number of requests the server is currently processing.
      def self.num_active_requests

Class variables form part of the global runtime state, and as such make it easy for one part of the system to accidentally or inadvertently depend on another part of the system. So the system becomes more prone to problems where changing something over here breaks something over there. In particular, class variables can make it hard to set up tests (because the context of the test includes all global state).

For a detailed explanation, check out this article

Example

Given

class Dummy
  @@class_variable = :whatever
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Dummy declares the class variable @@class_variable (ClassVariable)

Getting rid of the smell

You can use class-instance variable to mitigate the problem (as also suggested in the linked article above):

class Dummy
  @class_variable = :whatever
end

Gitlab::Testing::RequestBlockerMiddleware declares the class variable '@@num_active_requests'
Open

      @@num_active_requests = Concurrent::AtomicFixnum.new(0)
      @@block_requests = Concurrent::AtomicBoolean.new(false)
      @@slow_requests = Concurrent::AtomicBoolean.new(false)

      # Returns the number of requests the server is currently processing.

Class variables form part of the global runtime state, and as such make it easy for one part of the system to accidentally or inadvertently depend on another part of the system. So the system becomes more prone to problems where changing something over here breaks something over there. In particular, class variables can make it hard to set up tests (because the context of the test includes all global state).

For a detailed explanation, check out this article

Example

Given

class Dummy
  @@class_variable = :whatever
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Dummy declares the class variable @@class_variable (ClassVariable)

Getting rid of the smell

You can use class-instance variable to mitigate the problem (as also suggested in the linked article above):

class Dummy
  @class_variable = :whatever
end

Gitlab::Testing::RequestBlockerMiddleware#block_request has unused parameter 'env'
Open

      def block_request(env)

Unused Parameter refers to methods with parameters that are unused in scope of the method.

Having unused parameters in a method is code smell because leaving dead code in a method can never improve the method and it makes the code confusing to read.

Example

Given:

class Klass
  def unused_parameters(x,y,z)
    puts x,y # but not z
  end
end

Reek would emit the following warning:

[2]:Klass#unused_parameters has unused parameter 'z' (UnusedParameters)

There are no issues that match your filters.

Category
Status