Skip to content
Snippets Groups Projects
Commit 37f89c0c authored by Robert Speicher's avatar Robert Speicher
Browse files

Correct RuboCop offenses

parent 993fcc78
No related branches found
No related tags found
1 merge request!136Prepare for absorb
Loading
Loading
@@ -44,7 +44,7 @@ module Gitlab
lines << line[1, line.size]
elsif m = /^(\w{40}) (\d+) (\d+)/.match(line)
commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i
commits[commit_id] = nil if !commits.key?(commit_id)
commits[commit_id] = nil unless commits.key?(commit_id)
info[lineno] = [commit_id, old_lineno]
end
end
Loading
Loading
Loading
Loading
@@ -220,7 +220,6 @@ module Gitlab
commit(repository, options, :remove)
end
 
# Rename file from repository and return commit sha
#
# options should contain next structure:
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ module Gitlab
:committed_date, :committer_name, :committer_email
].freeze
 
attr_accessor *SERIALIZE_KEYS
attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator
 
def ==(other)
return false unless other.is_a?(Gitlab::Git::Commit)
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ module Gitlab
 
DEFAULT_LIMITS = { max_files: 100, max_lines: 5000 }.freeze
 
def initialize(iterator, options={})
def initialize(iterator, options = {})
@iterator = iterator
@max_files = options.fetch(:max_files, DEFAULT_LIMITS[:max_files])
@max_lines = options.fetch(:max_lines, DEFAULT_LIMITS[:max_lines])
Loading
Loading
Loading
Loading
@@ -246,7 +246,7 @@ module Gitlab
 
# Return repo size in megabytes
def size
size = popen(%W(du -sk), path).first.strip.to_i
size = popen(%w(du -sk), path).first.strip.to_i
(size.to_f / 1024).round(2)
end
 
Loading
Loading
@@ -334,10 +334,10 @@ module Gitlab
def log_by_shell(sha, options)
cmd = %W(git --git-dir=#{path} log)
cmd += %W(-n #{options[:limit].to_i})
cmd += %W(--format=%H)
cmd += %w(--format=%H)
cmd += %W(--skip=#{options[:offset].to_i})
cmd += %W(--follow) if options[:follow]
cmd += %W(--no-merges) if options[:skip_merges]
cmd += %w(--follow) if options[:follow]
cmd += %w(--no-merges) if options[:skip_merges]
cmd += %W(--after=#{options[:after].iso8601}) if options[:after]
cmd += %W(--before=#{options[:before].iso8601}) if options[:before]
cmd += [sha]
Loading
Loading
@@ -460,7 +460,6 @@ module Gitlab
walker.sorting(Rugged::SORT_DATE)
end
 
commits = []
offset = actual_options[:skip]
limit = actual_options[:max_count]
Loading
Loading
@@ -933,7 +932,7 @@ module Gitlab
 
raw_output = IO.popen(cmd, &:read).split("\n").map do |f|
stuff, path = f.split("\t")
mode, type, sha = stuff.split(" ")
_mode, type, _sha = stuff.split(" ")
path if type == "blob"
# Contain only blob type
end
Loading
Loading
@@ -957,7 +956,7 @@ module Gitlab
gitattributes_content = blob_content(commit, '.gitattributes')
rescue InvalidBlobName
# No .gitattributes found. Should now remove any info/attributes and return
File.delete(info_attributes_path) if File.exists?(info_attributes_path)
File.delete(info_attributes_path) if File.exist?(info_attributes_path)
return
end
 
Loading
Loading
@@ -1119,7 +1118,7 @@ module Gitlab
end
end
 
def archive_to_file(treeish = 'master', filename = 'archive.tar.gz', format = nil, compress_cmd = %W(gzip -n))
def archive_to_file(treeish = 'master', filename = 'archive.tar.gz', format = nil, compress_cmd = %w(gzip -n))
git_archive_cmd = %W(git --git-dir=#{path} archive)
 
# Put files into a directory before archiving
Loading
Loading
@@ -1158,9 +1157,9 @@ module Gitlab
end
 
def nice(cmd)
nice_cmd = %W(nice -n 20)
nice_cmd = %w(nice -n 20)
unless unsupported_platform?
nice_cmd += %W(ionice -c 2 -n 7)
nice_cmd += %w(ionice -c 2 -n 7)
end
nice_cmd + cmd
end
Loading
Loading
@@ -1216,7 +1215,7 @@ module Gitlab
end
 
# Yield fake 'after' lines for the last line of file_contents
(count+1..count+SEARCH_CONTEXT_LINES).each do |i|
(count + 1..count + SEARCH_CONTEXT_LINES).each do |i|
yielder.yield [nil, i]
end
end
Loading
Loading
@@ -1226,7 +1225,7 @@ module Gitlab
# Loop through consecutive blocks of lines with indexes
lines_with_index.each_cons(2 * SEARCH_CONTEXT_LINES + 1) do |line_block|
# Get the 'middle' line and index from the block
line, i = line_block[SEARCH_CONTEXT_LINES]
line, _ = line_block[SEARCH_CONTEXT_LINES]
 
next unless line && line.match(/#{Regexp.escape(query)}/i)
 
Loading
Loading
Loading
Loading
@@ -12,8 +12,6 @@ module Gitlab
def message
encode! @message
end
private
end
end
end
Loading
Loading
@@ -26,4 +26,4 @@ Dir['test/*.rb'].each do |test_file|
end
 
desc 'Run all peformance tests'
task :default => tests
task default: tests
Loading
Loading
@@ -226,7 +226,7 @@ describe Gitlab::Git::Blob do
let(:repository) { Gitlab::Git::Repository.new(TEST_REPO_PATH) }
 
let(:commit_options) do
options = {
{
file: {
content: 'Lorem ipsum...',
path: 'documents/story.txt'
Loading
Loading
@@ -274,8 +274,8 @@ describe Gitlab::Git::Blob do
expect(commit.message).to eq('Wow such commit')
 
# Does not update any related ref
expect(repository.lookup("fix-mode").oid).to_not eq(commit.oid)
expect(repository.lookup("HEAD").oid).to_not eq(commit.oid)
expect(repository.lookup("fix-mode").oid).not_to eq(commit.oid)
expect(repository.lookup("HEAD").oid).not_to eq(commit.oid)
end
end
 
Loading
Loading
@@ -301,7 +301,7 @@ describe Gitlab::Git::Blob do
describe :rename do
let(:repository) { Gitlab::Git::Repository.new(TEST_NORMAL_REPO_PATH) }
let(:rename_options) do
options = {
{
file: {
path: 'NEWCONTRIBUTING.md',
previous_path: 'CONTRIBUTING.md',
Loading
Loading
@@ -326,7 +326,7 @@ describe Gitlab::Git::Blob do
end
 
let(:rename_options2) do
options = {
{
file: {
content: 'Lorem ipsum...',
path: 'bin/new_executable',
Loading
Loading
@@ -373,7 +373,7 @@ describe Gitlab::Git::Blob do
let(:repository) { Gitlab::Git::Repository.new(TEST_REPO_PATH) }
 
let(:commit_options) do
options = {
{
file: {
path: 'README.md'
},
Loading
Loading
Loading
Loading
@@ -132,7 +132,6 @@ describe Gitlab::Git::Commit do
end
end
 
describe "where" do
context 'path is empty string' do
subject do
Loading
Loading
Loading
Loading
@@ -35,7 +35,7 @@ describe Gitlab::Git::DiffCollection do
end
 
it 'avoids future iterator iterations' do
subject.decorate! { |d| d if !d.nil? }
subject.decorate! { |d| d unless d.nil? }
 
expect(iterator).not_to receive(:each)
 
Loading
Loading
@@ -365,7 +365,7 @@ describe Gitlab::Git::DiffCollection do
end
 
context 'when go over safe limits on files' do
let(:iterator) { [ fake_diff(1,1) ] * 4 }
let(:iterator) { [ fake_diff(1, 1) ] * 4 }
 
before(:each) do
stub_const('Gitlab::Git::DiffCollection::DEFAULT_LIMITS', { max_files: 2, max_lines: max_lines })
Loading
Loading
@@ -455,6 +455,6 @@ describe Gitlab::Git::DiffCollection do
end
 
def fake_diff(line_length, line_count)
{'diff' => "#{'a' * line_length}\n" * line_count}
{ 'diff' => "#{'a' * line_length}\n" * line_count }
end
end
Loading
Loading
@@ -112,7 +112,7 @@ EOT
end
 
describe 'straight diffs' do
let(:options) { { :straight => true } }
let(:options) { { straight: true } }
let(:diffs) { Gitlab::Git::Diff.between(repository, 'feature', 'master', options) }
subject { diffs }
 
Loading
Loading
@@ -125,9 +125,9 @@ EOT
context :diff do
subject { diffs.first }
 
it { should be_kind_of Gitlab::Git::Diff }
its(:new_path) { should == '.DS_Store' }
its(:diff) { should include 'Binary files /dev/null and b/.DS_Store differ' }
it { is_expected.to be_kind_of Gitlab::Git::Diff }
its(:new_path) { is_expected.to == '.DS_Store' }
its(:diff) { is_expected.to include 'Binary files /dev/null and b/.DS_Store differ' }
end
end
 
Loading
Loading
@@ -213,7 +213,7 @@ EOT
it { is_expected.to eq(9) }
end
 
its(:line_count) { should eq(9) }
its(:line_count) { is_expected.to eq(9) }
end
 
describe :too_large? do
Loading
Loading
Loading
Loading
@@ -213,9 +213,9 @@ describe Gitlab::Git::Repository do
it 'should have valid data' do
expect(submodule).to eq([
"six", {
"id"=>"409f37c4f05865e4fb208c771485f211a22c4c2d",
"path"=>"six",
"url"=>"git://github.com/randx/six.git"
"id" => "409f37c4f05865e4fb208c771485f211a22c4c2d",
"path" => "six",
"url" => "git://github.com/randx/six.git"
}
])
end
Loading
Loading
@@ -245,11 +245,12 @@ describe Gitlab::Git::Repository do
 
it 'should handle tags correctly' do
submodules = repository.submodules('v1.2.1')
expect(submodule).to eq([
expect(submodules.first).to eq([
"six", {
"id"=>"409f37c4f05865e4fb208c771485f211a22c4c2d",
"path"=>"six",
"url"=>"git://github.com/randx/six.git"
"id" => "409f37c4f05865e4fb208c771485f211a22c4c2d",
"path" => "six",
"url" => "git://github.com/randx/six.git"
}
])
end
Loading
Loading
@@ -338,7 +339,7 @@ describe Gitlab::Git::Repository do
end
 
it "should create a new branch" do
expect(@normal_repo.rugged.branches[new_branch]).to_not be_nil
expect(@normal_repo.rugged.branches[new_branch]).not_to be_nil
end
 
it "should move the HEAD to the correct commit" do
Loading
Loading
@@ -426,7 +427,6 @@ describe Gitlab::Git::Repository do
end
end
 
describe "#create_branch" do
before(:all) do
@repo = Gitlab::Git::Repository.new(TEST_MUTABLE_REPO_PATH)
Loading
Loading
@@ -831,7 +831,7 @@ describe Gitlab::Git::Repository do
it 'should reload Rugged::Repository and return master' do
expect(Rugged::Repository).to receive(:new).twice.and_call_original
 
branch = repository.find_branch('master')
repository.find_branch('master')
branch = repository.find_branch('master', force_reload: true)
 
expect(branch).to be_a_kind_of(Gitlab::Git::Branch)
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ module SeedHelper
GITLAB_URL = "https://gitlab.com/gitlab-org/gitlab-git-test.git"
 
def ensure_seeds
if File.exists?(SUPPORT_PATH)
if File.exist?(SUPPORT_PATH)
FileUtils.rm_r(SUPPORT_PATH)
end
 
Loading
Loading
@@ -91,6 +91,6 @@ bla/bla.txt
# Prevent developer git configurations from being persisted to test
# repositories
def git_env
{'GIT_TEMPLATE_DIR' => ''}
{ 'GIT_TEMPLATE_DIR' => '' }
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment