Skip to content

Commit

Permalink
Enable Layout/TrailingWhitespace cop and auto-correct offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
rspeicher committed Aug 15, 2017
1 parent 05151f7 commit 4edfad9
Show file tree
Hide file tree
Showing 53 changed files with 99 additions and 100 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Expand Up @@ -251,6 +251,10 @@ Layout/Tab:
Layout/TrailingBlankLines:
Enabled: true

# Avoid trailing whitespace.
Layout/TrailingWhitespace:
Enabled: true

# Style #######################################################################

# Check the naming of accessor methods for get_/set_.
Expand Down
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Expand Up @@ -57,11 +57,6 @@ Layout/SpaceInsideParens:
Layout/SpaceInsidePercentLiteralDelimiters:
Enabled: false

# Offense count: 89
# Cop supports --auto-correct.
Layout/TrailingWhitespace:
Enabled: false

# Offense count: 272
RSpec/EmptyLineAfterFinalLet:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/groups/application_controller.rb
Expand Up @@ -34,7 +34,7 @@ def authorize_admin_group_member!

def build_canonical_path(group)
params[:group_id] = group.to_param

url_for(params)
end
end
4 changes: 2 additions & 2 deletions app/controllers/omniauth_callbacks_controller.rb
Expand Up @@ -142,13 +142,13 @@ def handle_signup_error
def oauth
@oauth ||= request.env['omniauth.auth']
end

def fail_login
error_message = @user.errors.full_messages.to_sentence

return redirect_to omniauth_error_path(oauth['provider'], error: error_message)
end

def fail_ldap_login
flash[:alert] = 'Access denied for your LDAP account.'

Expand Down
24 changes: 12 additions & 12 deletions app/controllers/projects/cycle_analytics/events_controller.rb
Expand Up @@ -2,7 +2,7 @@ module Projects
module CycleAnalytics
class EventsController < Projects::ApplicationController
include CycleAnalyticsParams

before_action :authorize_read_cycle_analytics!
before_action :authorize_read_build!, only: [:test, :staging]
before_action :authorize_read_issue!, only: [:issue, :production]
Expand All @@ -11,33 +11,33 @@ class EventsController < Projects::ApplicationController
def issue
render_events(cycle_analytics[:issue].events)
end

def plan
render_events(cycle_analytics[:plan].events)
end

def code
render_events(cycle_analytics[:code].events)
end

def test
options(events_params)[:branch] = events_params[:branch_name]

render_events(cycle_analytics[:test].events)
end

def review
render_events(cycle_analytics[:review].events)
end

def staging
render_events(cycle_analytics[:staging].events)
end

def production
render_events(cycle_analytics[:production].events)
end

private

def render_events(events)
Expand All @@ -46,14 +46,14 @@ def render_events(events)
format.json { render json: { events: events } }
end
end

def cycle_analytics
@cycle_analytics ||= ::CycleAnalytics.new(project, options(events_params))
end

def events_params
return {} unless params[:events].present?

params[:events].permit(:start_date, :branch_name)
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/projects/merge_requests_controller.rb
Expand Up @@ -218,8 +218,8 @@ def ci_environments_status
if can?(current_user, :read_environment, environment) && environment.has_metrics?
metrics_project_environment_deployment_path(environment.project, environment, deployment)
end
metrics_monitoring_url =

metrics_monitoring_url =
if can?(current_user, :read_environment, environment)
environment_metrics_path(environment)
end
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/pipeline_schedules_helper.rb
@@ -1,10 +1,10 @@
module PipelineSchedulesHelper
def timezone_data
ActiveSupport::TimeZone.all.map do |timezone|
{
name: timezone.name,
offset: timezone.utc_offset,
identifier: timezone.tzinfo.identifier
ActiveSupport::TimeZone.all.map do |timezone|
{
name: timezone.name,
offset: timezone.utc_offset,
identifier: timezone.tzinfo.identifier
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/blob_viewer/notebook.rb
Expand Up @@ -2,7 +2,7 @@ module BlobViewer
class Notebook < Base
include Rich
include ClientSide

self.partial_name = 'notebook'
self.extensions = %w(ipynb)
self.binary = false
Expand Down
2 changes: 1 addition & 1 deletion app/models/deploy_keys_project.rb
Expand Up @@ -12,7 +12,7 @@ class DeployKeysProject < ActiveRecord::Base

def destroy_orphaned_deploy_key
return unless self.deploy_key.destroyed_when_orphaned? && self.deploy_key.orphaned?

self.deploy_key.destroy
end
end
2 changes: 1 addition & 1 deletion app/models/redirect_route.rb
Expand Up @@ -14,7 +14,7 @@ class RedirectRoute < ActiveRecord::Base
else
'redirect_routes.path = ? OR redirect_routes.path LIKE ?'
end

where(wheres, path, "#{sanitize_sql_like(path)}/%")
end
end
2 changes: 1 addition & 1 deletion app/serializers/project_entity.rb
@@ -1,6 +1,6 @@
class ProjectEntity < Grape::Entity
include RequestAwareEntity

expose :id
expose :name

Expand Down
2 changes: 1 addition & 1 deletion app/serializers/tree_root_entity.rb
@@ -1,7 +1,7 @@
# TODO: Inherit from TreeEntity, when `Tree` implements `id` and `name` like `Gitlab::Git::Tree`.
class TreeRootEntity < Grape::Entity
expose :path

expose :trees, using: TreeEntity
expose :blobs, using: BlobEntity
expose :submodules, using: SubmoduleEntity
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/0_acts_as_taggable.rb
Expand Up @@ -5,5 +5,5 @@
ActsAsTaggableOn.tags_counter = false

# validate that counter cache is disabled
raise "Counter cache is not disabled" if
raise "Counter cache is not disabled" if
ActsAsTaggableOn::Tagging.reflections["tag"].options[:counter_cache]
10 changes: 5 additions & 5 deletions config/initializers/static_files.rb
@@ -1,15 +1,15 @@
app = Rails.application

if app.config.serve_static_files
# The `ActionDispatch::Static` middleware intercepts requests for static files
# by checking if they exist in the `/public` directory.
# The `ActionDispatch::Static` middleware intercepts requests for static files
# by checking if they exist in the `/public` directory.
# We're replacing it with our `Gitlab::Middleware::Static` that does the same,
# except ignoring `/uploads`, letting those go through to the GitLab Rails app.

app.config.middleware.swap(
ActionDispatch::Static,
Gitlab::Middleware::Static,
app.paths["public"].first,
ActionDispatch::Static,
Gitlab::Middleware::Static,
app.paths["public"].first,
app.config.static_cache_control
)

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/trusted_proxies.rb
Expand Up @@ -2,7 +2,7 @@
# as the ActionDispatch::Request object. This is necessary for libraries
# like rack_attack where they don't use ActionDispatch, and we want them
# to block/throttle requests on private networks.
# Rack Attack specific issue: https://github.com/kickstarter/rack-attack/issues/145
# Rack Attack specific issue: https://github.com/kickstarter/rack-attack/issues/145
module Rack
class Request
def trusted_proxy?(ip)
Expand Down
2 changes: 1 addition & 1 deletion config/routes/repository.rb
Expand Up @@ -3,7 +3,7 @@
resource :repository, only: [:create] do
member do
get ':ref/archive', constraints: { format: Gitlab::PathRegex.archive_formats_regex, ref: /.+/ }, action: 'archive', as: 'archive'

# deprecated since GitLab 9.5
get 'archive', constraints: { format: Gitlab::PathRegex.archive_formats_regex }, as: 'archive_alternative'
end
Expand Down
@@ -1,7 +1,7 @@
class DefaultRequestAccessProjects < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false

def up
change_column_default :projects, :request_access_enabled, false
end
Expand Down
Expand Up @@ -21,7 +21,7 @@ def down
private

def up_mysql
# This is a trick to overcome MySQL limitation:
# This is a trick to overcome MySQL limitation:
# Mysql2::Error: Table 'ci_builds' is specified twice, both as a target for 'UPDATE' and as a separate source for data
# However, this leads to create a temporary table from `max(ci_builds.id)` which is slow and do full database update
execute <<-SQL.strip_heredoc
Expand Down
6 changes: 3 additions & 3 deletions db/post_migrate/20170523083112_migrate_old_artifacts.rb
Expand Up @@ -7,7 +7,7 @@ class MigrateOldArtifacts < ActiveRecord::Migration

# This uses special heuristic to find potential candidates for data migration
# Read more about this here: https://gitlab.com/gitlab-org/gitlab-ce/issues/32036#note_30422345

def up
builds_with_artifacts.find_each do |build|
build.migrate_artifacts!
Expand Down Expand Up @@ -51,14 +51,14 @@ def migrate_artifacts!
private

def source_artifacts_path
@source_artifacts_path ||=
@source_artifacts_path ||=
File.join(Gitlab.config.artifacts.path,
created_at.utc.strftime('%Y_%m'),
ci_id.to_s, id.to_s)
end

def target_artifacts_path
@target_artifacts_path ||=
@target_artifacts_path ||=
File.join(Gitlab.config.artifacts.path,
created_at.utc.strftime('%Y_%m'),
project_id.to_s, id.to_s)
Expand Down
2 changes: 1 addition & 1 deletion features/steps/profile/emails.rb
Expand Up @@ -28,7 +28,7 @@ class Spinach::Features::ProfileEmails < Spinach::FeatureSteps
expect(email).to be_nil
expect(page).not_to have_content("my@email.com")
end

step 'I click link "Remove" for "my@email.com"' do
# there should only be one remove button at this time
click_link "Remove"
Expand Down
2 changes: 1 addition & 1 deletion lib/api/entities.rb
Expand Up @@ -83,7 +83,7 @@ class BasicProjectDetails < Grape::Entity
expose :created_at, :last_activity_at
end

class Project < BasicProjectDetails
class Project < BasicProjectDetails
include ::API::Helpers::RelatedResourcesHelpers

expose :_links do
Expand Down
2 changes: 1 addition & 1 deletion lib/api/protected_branches.rb
Expand Up @@ -61,7 +61,7 @@ class ProtectedBranches < Grape::API
service_args = [user_project, current_user, protected_branch_params]

protected_branch = ::ProtectedBranches::CreateService.new(*service_args).execute

if protected_branch.persisted?
present protected_branch, with: Entities::ProtectedBranch, project: user_project
else
Expand Down
4 changes: 2 additions & 2 deletions lib/banzai/filter/image_lazy_load_filter.rb
Expand Up @@ -6,9 +6,9 @@ def call
doc.xpath('descendant-or-self::img').each do |img|
img['class'] ||= '' << 'lazy'
img['data-src'] = img['src']
img['src'] = LazyImageTagHelper.placeholder_image
img['src'] = LazyImageTagHelper.placeholder_image
end

doc
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/constraints/project_url_constrainer.rb
Expand Up @@ -7,7 +7,7 @@ def matches?(request)
return false unless DynamicPathValidator.valid_project_path?(full_path)

# We intentionally allow SELECT(*) here so result of this query can be used
# as cache for further Project.find_by_full_path calls within request
# as cache for further Project.find_by_full_path calls within request
Project.find_by_full_path(full_path, follow_redirects: request.get?).present?
end
end
2 changes: 1 addition & 1 deletion lib/declarative_policy/base.rb
Expand Up @@ -221,7 +221,7 @@ def disallowed?(*abilities)
end

# computes the given ability and prints a helpful debugging output
# showing which
# showing which
def debug(ability, *a)
runner(ability).debug(*a)
end
Expand Down
12 changes: 6 additions & 6 deletions lib/gitlab/auth/ip_rate_limiter.rb
Expand Up @@ -11,29 +11,29 @@ def initialize(ip)
def enabled?
config.enabled
end

def reset!
Rack::Attack::Allow2Ban.reset(ip, config)
end

def register_fail!
# Allow2Ban.filter will return false if this IP has not failed too often yet
@banned = Rack::Attack::Allow2Ban.filter(ip, config) do
# If we return false here, the failure for this IP is ignored by Allow2Ban
ip_can_be_banned?
end
end

def banned?
@banned
end

private

def config
Gitlab.config.rack_attack.git_basic_auth
end

def ip_can_be_banned?
config.ip_whitelist.exclude?(ip)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab/ci/build/artifacts/metadata.rb
Expand Up @@ -60,7 +60,7 @@ def match_entries(gz)
begin
path = read_string(gz).force_encoding('UTF-8')
meta = read_string(gz).force_encoding('UTF-8')

next unless path.valid_encoding? && meta.valid_encoding?
next unless path =~ match_pattern
next if path =~ INVALID_PATH_PATTERN
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab/git/blob.rb
Expand Up @@ -54,7 +54,7 @@ def binary?(data)
# [[commit_sha, path], [commit_sha, path], ...]. If blob_size_limit < 0 then the
# full blob contents are returned. If blob_size_limit >= 0 then each blob will
# contain no more than limit bytes in its data attribute.
#
#
# Keep in mind that this method may allocate a lot of memory. It is up
# to the caller to limit the number of blobs and blob_size_limit.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/gitlab/import_export/attributes_finder.rb
@@ -1,7 +1,7 @@
module Gitlab
module ImportExport
class AttributesFinder

def initialize(included_attributes:, excluded_attributes:, methods:)
@included_attributes = included_attributes || {}
@excluded_attributes = excluded_attributes || {}
Expand Down

0 comments on commit 4edfad9

Please sign in to comment.