Commit 0558447c authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'issue_344279_app_3' into 'master'

Fix Style/OpenStructUse offenses

See merge request gitlab-org/gitlab!75996
parents 47a44824 d8f5e12a
......@@ -7,9 +7,6 @@ Style/OpenStructUse:
- ee/spec/helpers/ee/blob_helper_spec.rb
- ee/spec/lib/gitlab/auth/group_saml/failure_handler_spec.rb
- ee/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb
- lib/api/wikis.rb
- lib/gitlab/git/diff_collection.rb
- lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
- lib/gitlab/testing/request_inspector_middleware.rb
- spec/factories/go_module_versions.rb
- spec/factories/wiki_pages.rb
......
......@@ -16,11 +16,11 @@ module API
end
def filename
object.file_name
object[:file_name]
end
def secure_url
object.file_path
object[:file_path]
end
end
end
......
......@@ -136,7 +136,7 @@ module API
if result[:status] == :success
status(201)
present OpenStruct.new(result[:result]), with: Entities::WikiAttachment
present result[:result], with: Entities::WikiAttachment
else
render_api_error!(result[:message], 400)
end
......
......@@ -9,8 +9,6 @@ module Gitlab
attr_reader :limits
delegate :max_files, :max_lines, :max_bytes, :safe_max_files, :safe_max_lines, :safe_max_bytes, to: :limits
def self.default_limits
{ max_files: ::Commit.diff_safe_max_files, max_lines: ::Commit.diff_safe_max_lines }
end
......@@ -26,8 +24,7 @@ module Gitlab
limits[:safe_max_lines] = [limits[:max_lines], defaults[:max_lines]].min
limits[:safe_max_bytes] = limits[:safe_max_files] * 5.kilobytes # Average 5 KB per file
limits[:max_patch_bytes] = Gitlab::Git::Diff.patch_hard_limit_bytes
OpenStruct.new(limits)
limits
end
def initialize(iterator, options = {})
......@@ -140,11 +137,11 @@ module Gitlab
end
def over_safe_limits?(files)
if files >= safe_max_files
if files >= limits[:safe_max_files]
@collapsed_safe_files = true
elsif @line_count > safe_max_lines
elsif @line_count > limits[:safe_max_lines]
@collapsed_safe_lines = true
elsif @byte_count >= safe_max_bytes
elsif @byte_count >= limits[:safe_max_bytes]
@collapsed_safe_bytes = true
end
......@@ -179,7 +176,7 @@ module Gitlab
@iterator.each_with_index do |raw, iterator_index|
@empty = false
if @enforce_limits && i >= max_files
if @enforce_limits && i >= limits[:max_files]
@overflow = true
@overflow_max_files = true
break
......@@ -194,7 +191,7 @@ module Gitlab
@line_count += diff.line_count
@byte_count += diff.diff.bytesize
if @enforce_limits && @line_count >= max_lines
if @enforce_limits && @line_count >= limits[:max_lines]
# This last Diff instance pushes us over the lines limit. We stop and
# discard it.
@overflow = true
......@@ -202,7 +199,7 @@ module Gitlab
break
end
if @enforce_limits && @byte_count >= max_bytes
if @enforce_limits && @byte_count >= limits[:max_bytes]
# This last Diff instance pushes us over the lines limit. We stop and
# discard it.
@overflow = true
......
......@@ -466,7 +466,7 @@ module Gitlab
request_params[:ignore_whitespace_change] = options.fetch(:ignore_whitespace_change, false)
request_params[:enforce_limits] = options.fetch(:limits, true)
request_params[:collapse_diffs] = !options.fetch(:expanded, true)
request_params.merge!(Gitlab::Git::DiffCollection.limits(options).to_h)
request_params.merge!(Gitlab::Git::DiffCollection.limits(options))
request = Gitaly::CommitDiffRequest.new(request_params)
response = GitalyClient.call(@repository.storage, :diff_service, :commit_diff, request, timeout: GitalyClient.medium_timeout)
......
......@@ -17,11 +17,11 @@ module Gitlab
public
def initialize(attributes = {})
@options = OpenStruct.new(attributes)
self.class.instance_eval do
def_delegators :@options, *attributes.keys
@options = attributes
end
def method_missing(method, *args)
@options[method]
end
def execute(current_user, project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment