diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e72b532e..c9bfadb9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -55,3 +55,7 @@ Style/CaseIndentation: # Offense count: 28 Style/Documentation: Enabled: false + +# Bug with this cop https://github.com/bbatsov/rubocop/issues/3283 +Lint/ShadowedException: + Enabled: false diff --git a/features/step_definitions/lolcommits_steps.rb b/features/step_definitions/lolcommits_steps.rb index 35117180..22f15d6e 100644 --- a/features/step_definitions/lolcommits_steps.rb +++ b/features/step_definitions/lolcommits_steps.rb @@ -165,7 +165,7 @@ def default_loldir end When(/^I do a git commit with commit message "(.*?)"$/) do |commit_msg| - filename = Faker::Lorem.words(1).first + filename = FFaker::Lorem.words(1).first steps %( Given a 98 byte file named "#{filename}" And I successfully run `git add #{filename}` @@ -174,7 +174,7 @@ def default_loldir end When(/^I do a git commit$/) do - step %(I do a git commit with commit message "#{Faker::Lorem.sentence}") + step %(I do a git commit with commit message "#{FFaker::Lorem.sentence}") end When(/^I do (\d+) git commits$/) do |n| @@ -190,7 +190,7 @@ def default_loldir end When(/^I do a mercurial commit with commit message "(.*?)"$/) do |commit_msg| - filename = Faker::Lorem.words(1).first + filename = FFaker::Lorem.words(1).first steps %( Given a 98 byte file named "#{filename}" And I successfully run `hg add #{filename}` @@ -199,7 +199,7 @@ def default_loldir end When(/^I do a mercurial commit$/) do - step %(I do a mercurial commit with commit message "#{Faker::Lorem.sentence}") + step %(I do a mercurial commit with commit message "#{FFaker::Lorem.sentence}") end When(/^I do (\d+) mercurial commits$/) do |n| diff --git a/features/support/path_helpers.rb b/features/support/path_helpers.rb index eabbedd9..685ff23a 100644 --- a/features/support/path_helpers.rb +++ b/features/support/path_helpers.rb @@ -24,7 +24,7 @@ def reject_paths_with_cmd(cmd) # add the temporary directory with git in it back into the path newpaths << tmpbindir - # use aruba/api set_env to set PATH, which will be automaticaly restored + # use aruba/api set_environment_variable to set PATH, which will be automaticaly restored set_env 'PATH', newpaths.join(File::PATH_SEPARATOR) end diff --git a/lib/lolcommits/backends/installation_git.rb b/lib/lolcommits/backends/installation_git.rb index 7ed48831..1febb107 100644 --- a/lib/lolcommits/backends/installation_git.rb +++ b/lib/lolcommits/backends/installation_git.rb @@ -42,7 +42,7 @@ def self.do_enable f.write(hook_script) end - FileUtils.chmod 0755, HOOK_PATH + FileUtils.chmod 0o755, HOOK_PATH HOOK_PATH end diff --git a/lib/lolcommits/configuration.rb b/lib/lolcommits/configuration.rb index 6d1b29ad..ff0ab256 100644 --- a/lib/lolcommits/configuration.rb +++ b/lib/lolcommits/configuration.rb @@ -124,7 +124,7 @@ def self.loldir_for(basename) if File.directory? loldir begin # ensure 755 permissions for loldir - File.chmod(0755, loldir) + File.chmod(0o755, loldir) rescue Errno::EPERM # abort if permissions cannot be met puts "FATAL: directory '#{loldir}' should be present and writeable by user '#{ENV['USER']}'" diff --git a/lib/lolcommits/plugins/dot_com.rb b/lib/lolcommits/plugins/dot_com.rb index 4fc4c654..04467db2 100644 --- a/lib/lolcommits/plugins/dot_com.rb +++ b/lib/lolcommits/plugins/dot_com.rb @@ -27,7 +27,8 @@ def run_postcapture :key => configuration['api_key'], :t => t, :token => Digest::SHA1.hexdigest(configuration['api_secret'] + t) - }) + } + ) rescue => e log_error(e, "ERROR: HTTMultiParty POST FAILED #{e.class} - #{e.message}") end diff --git a/lib/lolcommits/plugins/lol_protonet.rb b/lib/lolcommits/plugins/lol_protonet.rb index 50fc752b..792fb1a3 100644 --- a/lib/lolcommits/plugins/lol_protonet.rb +++ b/lib/lolcommits/plugins/lol_protonet.rb @@ -37,17 +37,18 @@ def random_object end def random_adjective - adjectives = ['awesome', 'great', 'interesting', 'cool', 'EPIC', 'gut', 'good', 'pansy', - 'powerful', 'boring', 'quirky', 'untested', 'german', 'iranian', 'neutral', 'crazy', 'well tested', - 'jimmy style', 'nasty', 'bibliographical (we received complaints about the original wording)', - 'bombdiggidy', 'narly', 'spiffy', 'smashing', 'xing style', - 'leo apotheker style', 'black', 'white', 'yellow', 'shaggy', 'tasty', 'mind bending', 'JAY-Z', - 'Kanye (the best ever)', '* Toby Keith was here *', 'splendid', 'stupendulous', - '(freedom fries!)', '[vote RON PAUL]', '- these are not my glasses -', 'typical pansy', - '- ze goggles zey do nothing! -', 'almost working', 'legen- wait for it -', '-dairy!', - ' - Tavonius would be proud of this - ', 'Meg FAILMAN!', '- very brofessional of you -', - 'heartbleeding', 'juciy', 'supercalifragilisticexpialidocious', 'failing', 'loving' - ] + adjectives = [ + 'awesome', 'great', 'interesting', 'cool', 'EPIC', 'gut', 'good', 'pansy', + 'powerful', 'boring', 'quirky', 'untested', 'german', 'iranian', 'neutral', 'crazy', 'well tested', + 'jimmy style', 'nasty', 'bibliographical (we received complaints about the original wording)', + 'bombdiggidy', 'narly', 'spiffy', 'smashing', 'xing style', + 'leo apotheker style', 'black', 'white', 'yellow', 'shaggy', 'tasty', 'mind bending', 'JAY-Z', + 'Kanye (the best ever)', '* Toby Keith was here *', 'splendid', 'stupendulous', + '(freedom fries!)', '[vote RON PAUL]', '- these are not my glasses -', 'typical pansy', + '- ze goggles zey do nothing! -', 'almost working', 'legen- wait for it -', '-dairy!', + ' - Tavonius would be proud of this - ', 'Meg FAILMAN!', '- very brofessional of you -', + 'heartbleeding', 'juciy', 'supercalifragilisticexpialidocious', 'failing', 'loving' + ] adjectives.sample end diff --git a/lib/lolcommits/plugins/lol_slack.rb b/lib/lolcommits/plugins/lol_slack.rb index 53a3b6b7..d7533507 100644 --- a/lib/lolcommits/plugins/lol_slack.rb +++ b/lib/lolcommits/plugins/lol_slack.rb @@ -53,7 +53,8 @@ def run_postcapture :filetype => 'jpg', :filename => runner.sha, :title => runner.message + "[#{runner.vcs_info.repo}]", - :channels => configuration['channels']) + :channels => configuration['channels'] + ) debug response rescue => e diff --git a/lib/lolcommits/plugins/lol_tumblr.rb b/lib/lolcommits/plugins/lol_tumblr.rb index 9278c677..45e37eff 100644 --- a/lib/lolcommits/plugins/lol_tumblr.rb +++ b/lib/lolcommits/plugins/lol_tumblr.rb @@ -81,20 +81,22 @@ def configured? end def client - @client ||= Tumblr.new(:consumer_key => TUMBLR_CONSUMER_KEY, - :consumer_secret => TUMBLR_CONSUMER_SECRET, - :oauth_token => configuration['access_token'], - :oauth_token_secret => configuration['secret'] - ) + @client ||= Tumblr.new( + :consumer_key => TUMBLR_CONSUMER_KEY, + :consumer_secret => TUMBLR_CONSUMER_SECRET, + :oauth_token => configuration['access_token'], + :oauth_token_secret => configuration['secret'] + ) end def oauth_consumer - @oauth_consumer ||= OAuth::Consumer.new(TUMBLR_CONSUMER_KEY, - TUMBLR_CONSUMER_SECRET, - :site => TUMBLR_API_ENDPOINT, - :request_endpoint => TUMBLR_API_ENDPOINT, - :http_methdo => :get - ) + @oauth_consumer ||= OAuth::Consumer.new( + TUMBLR_CONSUMER_KEY, + TUMBLR_CONSUMER_SECRET, + :site => TUMBLR_API_ENDPOINT, + :request_endpoint => TUMBLR_API_ENDPOINT, + :http_method => :get + ) end def config_with_default(key, default = nil) diff --git a/lib/lolcommits/plugins/lolsrv.rb b/lib/lolcommits/plugins/lolsrv.rb index 4be145a4..1709f935 100644 --- a/lib/lolcommits/plugins/lolsrv.rb +++ b/lib/lolcommits/plugins/lolsrv.rb @@ -29,8 +29,7 @@ def sync end def existing_lols - lols = JSON.parse( - RestClient.get(configuration['server'] + '/lols')) + lols = JSON.parse(RestClient.get(configuration['server'] + '/lols')) lols.map { |lol| lol['sha'] } rescue => e log_error(e, "ERROR: existing lols could not be retrieved #{e.class} - #{e.message}") diff --git a/lib/lolcommits/plugins/uploldz.rb b/lib/lolcommits/plugins/uploldz.rb index 7454b504..fedf919d 100644 --- a/lib/lolcommits/plugins/uploldz.rb +++ b/lib/lolcommits/plugins/uploldz.rb @@ -25,18 +25,19 @@ def run_postcapture puts 'Repo is empty, skipping upload' else debug "Posting capture to #{configuration['endpoint']}" - RestClient.post(configuration['endpoint'], - { - :file => File.new(runner.main_image), - :message => runner.message, - :repo => runner.vcs_info.repo, - :author_name => runner.vcs_info.author_name, - :author_email => runner.vcs_info.author_email, - :sha => runner.sha, - :key => configuration['optional_key'] - }, - :Authorization => authorization_header - ) + RestClient.post( + configuration['endpoint'], + { + :file => File.new(runner.main_image), + :message => runner.message, + :repo => runner.vcs_info.repo, + :author_name => runner.vcs_info.author_name, + :author_email => runner.vcs_info.author_email, + :sha => runner.sha, + :key => configuration['optional_key'] + }, + :Authorization => authorization_header + ) end rescue => e log_error(e, "ERROR: RestClient POST FAILED #{e.class} - #{e.message}") diff --git a/lolcommits.gemspec b/lolcommits.gemspec index ca277944..08f0be48 100644 --- a/lolcommits.gemspec +++ b/lolcommits.gemspec @@ -29,15 +29,17 @@ Gem::Specification.new do |s| s.requirements << 'a webcam' # hold back upgrading (and why) - s.add_runtime_dependency('rest-client', '=1.8') # yam gem requires uses this older version - s.add_runtime_dependency('mime-types', '=2.99') # ~> 3.0+ requires Ruby >= 2.0 - s.add_development_dependency('tins', '=1.6.0') # ~> 1.7.0+ requires Ruby >= 2.0 + s.add_runtime_dependency('rest-client', '=1.8') # yam gem requires uses this older version + s.add_runtime_dependency('mime-types', '=2.99') # ~> 3.0+ requires Ruby >= 2.0 + s.add_runtime_dependency('json', '~> 1.8.3') # ~> 2.0+ requires Ruby >= 2.0 (lolsrv) + s.add_development_dependency('tins', '=1.6.0') # ~> 1.7.0+ requires Ruby >= 2.0 + s.add_development_dependency('rake', '~> 10.5.0') # ~> 11+ introduces lots of warnings from other deps # core - s.add_runtime_dependency('choice', '~> 0.2.0') s.add_runtime_dependency('methadone', '~> 1.8.0') - s.add_runtime_dependency('mercurial-ruby', '~> 0') + s.add_runtime_dependency('choice', '~> 0.2.0') + s.add_runtime_dependency('mercurial-ruby', '~> 0.7.12') s.add_runtime_dependency('mini_magick', '~> 4.5.1') s.add_runtime_dependency('launchy', '~> 2.4.3') s.add_runtime_dependency('open4', '~> 1.3.4') @@ -46,23 +48,21 @@ Gem::Specification.new do |s| # plugin gems s.add_runtime_dependency('twitter', '~> 5.13.0') # twitter s.add_runtime_dependency('oauth', '~> 0.4.7') # twitter oauth - s.add_runtime_dependency('json', '~> 1.8.1') # lolsrv s.add_runtime_dependency('yam', '~> 2.5.0') # yammer s.add_runtime_dependency('httmultiparty', '~> 0.3.16') # dot_com s.add_runtime_dependency('tumblr_client', '~> 0.8.5') # tumblr # development gems - s.add_development_dependency('rdoc', '~> 4.2.0') - s.add_development_dependency('rake', '~> 10.4.2') + s.add_development_dependency('rdoc', '~> 4.2.2') # testing gems s.add_development_dependency('aruba', '~> 0.6.2') - s.add_development_dependency('ffaker', '~> 1.25.0') - s.add_development_dependency('coveralls', '~> 0.7.2') - s.add_development_dependency('minitest', '~> 5.5.1') - s.add_development_dependency('travis', '~> 1.7.4') - s.add_development_dependency('rubocop', '~> 0.37.2') + s.add_development_dependency('rubocop', '~> 0.41.0') + s.add_development_dependency('travis', '~> 1.8.2') + s.add_development_dependency('minitest', '~> 5.9.0') + s.add_development_dependency('coveralls', '~> 0.8.13') + s.add_development_dependency('ffaker', '~> 2.2.0') s.add_development_dependency('cucumber', '~> 2.4.0') end diff --git a/test/lolcommits_test.rb b/test/lolcommits_test.rb index 027a17f7..eb98f12c 100644 --- a/test/lolcommits_test.rb +++ b/test/lolcommits_test.rb @@ -1,8 +1,6 @@ # -*- encoding : utf-8 -*- -if RUBY_VERSION >= '2.0.0' - require 'coveralls' - Coveralls.wear! -end +require 'coveralls' +Coveralls.wear! require 'minitest/autorun' @@ -20,18 +18,18 @@ class LolTest < MiniTest::Test # this will test the permissions but only locally, important before building a gem package! # def test_permissions - impact_perms = File.lstat(Lolcommits::Loltext::DEFAULT_FONT_PATH).mode & 0777 - imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')).mode & 0777 - videosnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')).mode & 0777 - commandcam_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')).mode & 0777 + impact_perms = File.lstat(Lolcommits::Loltext::DEFAULT_FONT_PATH).mode & 0o777 + imagesnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'imagesnap', 'imagesnap')).mode & 0o777 + videosnap_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'videosnap', 'videosnap')).mode & 0o777 + commandcam_perms = File.lstat(File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', 'CommandCam', 'CommandCam.exe')).mode & 0o777 - assert impact_perms == 0644 || impact_perms == 0664, + assert impact_perms == 0o644 || impact_perms == 0o664, "expected perms of 644/664 but instead got #{format '%o', impact_perms}" - assert imagesnap_perms == 0755 || imagesnap_perms == 0775, + assert imagesnap_perms == 0o755 || imagesnap_perms == 0o775, "expected perms of 755/775 but instead got #{format '%o', imagesnap_perms}" - assert videosnap_perms == 0755 || videosnap_perms == 0775, + assert videosnap_perms == 0o755 || videosnap_perms == 0o775, "expected perms of 755/775 but instead got #{format '%o', videosnap_perms}" - assert commandcam_perms == 0755 || commandcam_perms == 0775, + assert commandcam_perms == 0o755 || commandcam_perms == 0o775, "expected perms of 755/775 but instead got #{format '%o', commandcam_perms}" end end diff --git a/test/plugins_test.rb b/test/plugins_test.rb index b9a33f33..9dbb4fec 100644 --- a/test/plugins_test.rb +++ b/test/plugins_test.rb @@ -1,8 +1,6 @@ # -*- encoding : utf-8 -*- -if RUBY_VERSION >= '2.0.0' - require 'coveralls' - Coveralls.wear! -end +require 'coveralls' +Coveralls.wear! require 'minitest/autorun' require 'ffaker' @@ -29,7 +27,7 @@ def test_tranzlate # # issue #136, https://github.com/mroth/lolcommits/issues/136 def test_lol_twitter_build_tweet - long_commit_message = Faker::Lorem.sentence(500) + long_commit_message = FFaker::Lorem.sentence(500) plugin = Lolcommits::LolTwitter.new(nil) max_tweet_size = 116 suffix = '... #lolcommits'