Skip to content

Commit

Permalink
Unsafe offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Sep 14, 2024
1 parent 88ec009 commit 7dc52bf
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 35 deletions.
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ Metrics/ModuleLength:
Exclude:
- 'spec/**/*'

RSpec/ExampleLength:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Max: 10

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma

Expand Down
79 changes: 71 additions & 8 deletions .rubocop_todo.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/lib/autoheathen/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe AutoHeathen::Config do
before :all do
@clazz = Class.new
@clazz.include AutoHeathen::Config
@clazz.include described_class
end

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/autoheathen/email_processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

RSpec.describe AutoHeathen::EmailProcessor do
let(:processor) {
AutoHeathen::EmailProcessor.new({
described_class.new({
cc_blacklist: ['wikilex@ifad.org'],
}, fixture('autoheathen/autoheathen.yml'))
}
Expand Down
34 changes: 17 additions & 17 deletions spec/lib/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

describe '.exists?' do
it 'runs' do
expect(described_class.exists?(storage_dir, doc_key)).to eq true
expect(described_class.exists?(storage_dir, doc_key)).to be true
end

it 'returns false if directory does not exist' do
expect(described_class.exists?(storage_dir, invalid_doc_key)).to eq false
expect(described_class.exists?(storage_dir, invalid_doc_key)).to be false
end
end

Expand All @@ -39,7 +39,7 @@
create_key = Colore::DocKey.new('app2', 'foo')
doc = described_class.create storage_dir, create_key
expect(doc).not_to be_nil
expect(described_class.exists?(storage_dir, create_key)).to eq true
expect(described_class.exists?(storage_dir, create_key)).to be true
end

it 'raises error if doc already exists' do
Expand All @@ -64,16 +64,16 @@

describe '.delete' do
it 'runs' do
Colore::Document.delete storage_dir, doc_key
expect(Colore::Document.exists?(storage_dir, doc_key)).to eq false
described_class.delete storage_dir, doc_key
expect(described_class.exists?(storage_dir, doc_key)).to be false
end
end

describe '#directory' do
it 'runs' do
dir = document.directory
expect(dir).not_to be_nil
expect(File.exist?(dir)).to eq true
expect(File.exist?(dir)).to be true
end
end

Expand Down Expand Up @@ -105,15 +105,15 @@

describe '#has_version?' do
it 'runs' do
expect(document.has_version?('v001')).to eq true
expect(document.has_version?('v001')).to be true
end

it 'accepts current' do
expect(document.has_version?('current')).to eq true
expect(document.has_version?('current')).to be true
end

it 'rejects invalid' do
expect(document.has_version?('foo')).to eq false
expect(document.has_version?('foo')).to be false
end
end

Expand All @@ -133,9 +133,9 @@
it 'runs' do
version = document.new_version
expect(version).not_to be_nil
expect(File.exist?(document.directory + version)).to eq true
expect(File.exist?(document.directory + version)).to be true
new_doc = described_class.load storage_dir, doc_key
expect(new_doc.versions.include?(version)).to eq true
expect(new_doc.versions.include?(version)).to be true
end
end

Expand All @@ -144,23 +144,23 @@
file = __FILE__
body = File.read(file)
document.add_file 'v002', File.basename(file), body
expect(File.exist?(document.directory + 'v002' + File.basename(file))).to eq true
expect(File.exist?(document.directory + 'v002' + File.basename(file))).to be true
end

it 'runs with author' do
file = __FILE__
body = File.read(file)
document.add_file 'v002', File.basename(file), body, author
expect(File.exist?(document.directory + 'v002' + File.basename(file))).to eq true
expect(File.exist?(document.directory + 'v002' + described_class::AUTHOR_FILE)).to eq true
expect(File.exist?(document.directory + 'v002' + File.basename(file))).to be true
expect(File.exist?(document.directory + 'v002' + described_class::AUTHOR_FILE)).to be true
expect(File.read(document.directory + 'v002' + described_class::AUTHOR_FILE).chomp).to eq author
end

it 'runs with IO for body' do
file = __FILE__
body = File.open(file)
document.add_file 'v002', File.basename(file), body
expect(File.exist?(document.directory + 'v002' + File.basename(file))).to eq true
expect(File.exist?(document.directory + 'v002' + File.basename(file))).to be true
end
end

Expand Down Expand Up @@ -188,7 +188,7 @@
describe '#delete_version' do
it 'runs' do
document.delete_version 'v001'
expect(File.exist?(document.directory + 'v001')).to eq false
expect(File.exist?(document.directory + 'v001')).to be false
end

it 'refuses to delete "current"' do
Expand Down Expand Up @@ -266,7 +266,7 @@
describe '#save_metadata' do
it 'runs' do
document.save_metadata
expect(File.exist?(document.directory + 'metadata.json')).to eq true
expect(File.exist?(document.directory + 'metadata.json')).to be true
# expect this to pass
JSON.parse File.read(document.directory + 'metadata.json')
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/legacy_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
it 'runs' do
new_filename = converter.convert_file new_format, content
expect(new_filename).not_to be_nil
expect((storage_dir + new_filename).file?).to eq true
expect((storage_dir + new_filename).file?).to be true
stored_content = File.read(storage_dir + new_filename)
expect(stored_content).to eq 'The quick brown fox'
end
Expand All @@ -33,7 +33,7 @@
filename = 'foo.txt'
content = 'The quick brown fox'
converter.store_file filename, content
expect((converter.legacy_dir + filename).file?).to eq true
expect((converter.legacy_dir + filename).file?).to be true
expect(File.read(converter.legacy_dir + filename)).to eq content
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/sidekiq_workers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@
file1.open('w') { |f| f.write 'foobar' }
file2.open('w') { |f| f.write 'foobar' }
described_class.new.perform
expect(file1.file?).to eq true
expect(file2.file?).to eq true
expect(file1.file?).to be true
expect(file2.file?).to be true
Timecop.freeze(Date.today + 1)
described_class.new.perform
expect(file1.file?).to eq true
expect(file2.file?).to eq true
expect(file1.file?).to be true
expect(file2.file?).to be true
Timecop.freeze(Date.today + 3)
described_class.new.perform
expect(file1.file?).to eq false
expect(file2.file?).to eq false
expect(file1.file?).to be false
expect(file2.file?).to be false
end
end
end

0 comments on commit 7dc52bf

Please sign in to comment.