Skip to content

Commit

Permalink
Auto merge of #174 - matthewalbani:update-rubocop, r=bronzdoc
Browse files Browse the repository at this point in the history
Update rubocop to .49 to fix CVE-2017-8418

update rubocop to fix vuln CVE-2017-8418

rubocop/rubocop#4336
  • Loading branch information
bundlerbot committed Mar 31, 2018
2 parents b091edd + d6cd183 commit 8409634
Show file tree
Hide file tree
Showing 34 changed files with 202 additions and 149 deletions.
57 changes: 49 additions & 8 deletions .rubocop-bundler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ Lint/AssignmentInCondition:
Enabled: false

Lint/EndAlignment:
AlignWith: variable
EnforcedStyleAlignWith: variable

Lint/UnusedMethodArgument:
Enabled: false

# Style

Style/AccessModifierIndentation:
Layout/AccessModifierIndentation:
EnforcedStyle: outdent

Style/AlignParameters:
Layout/AlignParameters:
EnforcedStyle: with_fixed_indentation

Style/MultilineOperationIndentation:
Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Style/SpaceInsideBlockBraces:
Layout/SpaceInsideBlockBraces:
SpaceBeforeBlockParameters: false

Style/TrivialAccessors:
Expand All @@ -47,7 +47,10 @@ Style/StringLiteralsInInterpolation:

# Having these make it easier to *not* forget to add one when adding a new
# value and you can simply copy the previous line.
Style/TrailingComma:
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma

# 1.8.7 support
Expand All @@ -58,7 +61,7 @@ Style/HashSyntax:
Style/Lambda:
Enabled: false

Style/DotPosition:
Layout/DotPosition:
EnforcedStyle: trailing

Style/EachWithObject:
Expand All @@ -67,7 +70,17 @@ Style/EachWithObject:
Style/SpecialGlobalVars:
Enabled: false

Style/TrailingComma:
Style/TrailingCommaInArguments:
Enabled: false

Style/TrailingCommaInLiteral:
Enabled: false

Style/VariableNumber:
EnforcedStyle: 'snake_case'

#alerts on some large if blocks
Style/GuardClause:
Enabled: false

# Metrics
Expand All @@ -93,3 +106,31 @@ Metrics/CyclomaticComplexity:

Metrics/PerceivedComplexity:
Enabled: false

Metrics/BlockLength:
Enabled: false

Metrics/LineLength:
Enabled: false

#Security

Security/MarshalLoad:
Enabled: false

Security/YAMLLoad:
Enabled: false

#Ignore certain test cases
Bundler/DuplicatedGem:
Exclude:
- spec/data/bundles/**/Gemfile

Style/GlobalVars:
Exclude:
- spec/support/test_gemstash_server.ru

#changing this causes the jruby build to wedge
Style/ConditionalAssignment:
Exclude:
- spec/concurrency_spec.rb
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ matrix:
- rvm: ruby-head
gemfile: 'gemfiles/Gemfile.ruby-head'
- rvm: jruby-9.1.13.0
env: JRUBY_OPTS="--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -Xcompile.invokedynamic=false -J-Xmx1536m"
env:
- JRUBY_OPTS="--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -Xcompile.invokedynamic=false -J-Xmx1536m"
- JAVA_OPTS="-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1"

bundler_args: "--binstubs --jobs=3 --retry=3"

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RuboCop::RakeTask.new

desc "Run specs"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w(--color)
t.rspec_opts = %w[--color]
end

task spec: :rubocop
Expand Down
3 changes: 2 additions & 1 deletion gemstash.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "gemstash/version"
Expand Down Expand Up @@ -57,5 +58,5 @@ you push your own private gems as well."
spec.add_development_dependency "rack-test", "~> 0.6"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.3"
spec.add_development_dependency "rubocop", "0.35.1"
spec.add_development_dependency "rubocop", "0.49"
end
2 changes: 1 addition & 1 deletion lib/gemstash/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NotAuthorizedError < StandardError
class Authorization
extend Gemstash::Env::Helper
extend Gemstash::Logging
VALID_PERMISSIONS = %w(push yank fetch).freeze
VALID_PERMISSIONS = %w[push yank fetch].freeze

def self.authorize(auth_key, permissions)
raise "Authorization key is required!" if auth_key.to_s.strip.empty?
Expand Down
6 changes: 3 additions & 3 deletions lib/gemstash/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def self.exit_on_failure?
end

def self.start(args = ARGV)
help_flags = %w(-h --help)
help_flags = %w[-h --help]

if args.any? {|a| help_flags.include?(a) }
super(%w(help) + args.reject {|a| help_flags.include?(a) })
super(%w[help] + args.reject {|a| help_flags.include?(a) })
else
super
end
Expand Down Expand Up @@ -95,7 +95,7 @@ def stop
def version
say "Gemstash version #{Gemstash::VERSION}"
end
map %w(-v --version) => :version
map %w[-v --version] => :version

private

Expand Down
6 changes: 4 additions & 2 deletions lib/gemstash/cli/authorize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ def setup_logging
end

def remove_authorization
raise Gemstash::CLI::Error.new(@cli, "To remove individual permissions, you do not need --remove
Instead just authorize with the new set of permissions") unless @args.empty?
unless @args.empty?
raise Gemstash::CLI::Error.new(@cli, "To remove individual permissions, you do not need --remove
Instead just authorize with the new set of permissions")
end
Gemstash::Authorization.remove(auth_key(false))
end

Expand Down
9 changes: 5 additions & 4 deletions lib/gemstash/cli/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def prepare
end

def check_rubygems_version
@cli.say(@cli.set_color("Rubygems version is too old, " \
"please update rubygems by running: " \
"gem update --system", :red)) unless
Gem::Requirement.new(">= 2.4").satisfied_by?(Gem::Version.new(Gem::VERSION))
unless Gem::Requirement.new(">= 2.4").satisfied_by?(Gem::Version.new(Gem::VERSION))
@cli.say(@cli.set_color("Rubygems version is too old, " \
"please update rubygems by running: " \
"gem update --system", :red))
end
end

def store_config
Expand Down
4 changes: 2 additions & 2 deletions lib/gemstash/cli/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def ask_storage

def ask_cache
say_current_config(:cache_type, "Current cache")
@config[:cache_type] = ask_with_default("Cache with what?", %w(memory memcached), "memory")
@config[:cache_type] = ask_with_default("Cache with what?", %w[memory memcached], "memory")
ask_memcached_details if @config[:cache_type] == "memcached"
end

Expand All @@ -85,7 +85,7 @@ def ask_memcached_details

def ask_database
say_current_config(:db_adapter, "Current database adapter")
@config[:db_adapter] = ask_with_default("What database adapter?", %w(sqlite3 postgres mysql mysql2), "sqlite3")
@config[:db_adapter] = ask_with_default("What database adapter?", %w[sqlite3 postgres mysql mysql2], "sqlite3")
ask_database_details(@config[:db_adapter]) unless @config[:db_adapter] == "sqlite3"
end

Expand Down
2 changes: 1 addition & 1 deletion lib/gemstash/cli/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run
private

def args
pidfile_args + %w(status)
pidfile_args + %w[status]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/gemstash/cli/stop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def run
private

def args
pidfile_args + %w(stop)
pidfile_args + %w[stop]
end
end
end
Expand Down
6 changes: 2 additions & 4 deletions lib/gemstash/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ def initialize(level)
@level = level
end

def flush
end
def flush; end

def sync=(_value)
end
def sync=(_value); end

def write(message)
Gemstash::Logging.logger.add(@level, message)
Expand Down
4 changes: 2 additions & 2 deletions lib/gemstash/migrations/01_gem_dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
TrueClass :prerelease, :null => false
DateTime :created_at, :null => false
DateTime :updated_at, :null => false
index [:rubygem_id, :number, :platform], :unique => true
index %i[rubygem_id number platform], :unique => true
index [:indexed]
index [:indexed, :prerelease]
index %i[indexed prerelease]
index [:number]
index [:full_name], :unique => true
index [:storage_id], :unique => true
Expand Down
2 changes: 1 addition & 1 deletion lib/gemstash/migrations/03_cached_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
String :resource_type, size: 191, null: false
DateTime :created_at, null: false
DateTime :updated_at, null: false
index [:upstream_id, :resource_type, :name], unique: true
index %i[upstream_id resource_type name], unique: true
index [:name]
end
end
Expand Down
6 changes: 3 additions & 3 deletions rake/doc/fix_github_line_breaks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# formatted properly.

# First test that the problem still exists
PANDOC_MD_INPUT = "Multiple lines\\\nwith explicit\\\nline breaks"
INVALID_EXPECTED_MD_OUTPUT = "Multiple lines\nwith explicit\nline breaks\n"
PANDOC_MD_INPUT = "Multiple lines\\\nwith explicit\\\nline breaks".freeze
INVALID_EXPECTED_MD_OUTPUT = "Multiple lines\nwith explicit\nline breaks\n".freeze

pandoc_results = nil

Expand All @@ -35,7 +35,7 @@
element.elements.each_with_index do |e, i|
next unless e.is_a?(PandocObjectFilters::Element::LineBreak)

if i == 0
if i.zero?
STDERR.puts "[#{File.basename(__FILE__)}][WARNING] Found line break at the beginning of a block!"
next
end
Expand Down
2 changes: 1 addition & 1 deletion rake/doc/insert_github_generation_comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "open3"
require "pandoc_object_filters"

COMMENT = %(<!--Automatically generated by Pandoc -->)
COMMENT = %(<!--Automatically generated by Pandoc -->).freeze

def github_comment
pandoc_results = nil
Expand Down
6 changes: 3 additions & 3 deletions rake/doc/insert_images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
require "open3"
require "pandoc_object_filters"

HTML_IMAGES = %(<p align="center"><img src="gemstash.png" /></p>)
HTML_IMAGES = %(<p align="center"><img src="gemstash.png" /></p>).freeze
GITHUB_IMAGES = %([![Build Status][TRAVIS_IMG]][TRAVIS] [![Code Climate][CODE_CLIMATE_IMG]][CODE_CLIMATE]
[TRAVIS_IMG]: https://travis-ci.org/bundler/gemstash.svg?branch=master
[TRAVIS]: https://travis-ci.org/bundler/gemstash
[CODE_CLIMATE_IMG]: https://codeclimate.com/github/bundler/gemstash/badges/gpa.svg
[CODE_CLIMATE]: https://codeclimate.com/github/bundler/gemstash
<p align="center"><img src="gemstash.png" /></p>)
<p align="center"><img src="gemstash.png" /></p>).freeze

def images_json(markdown)
pandoc_results = nil
Expand Down Expand Up @@ -41,7 +41,7 @@ def images_json(markdown)

filter.filter! do |element|
next if found
next unless %w(html markdown_github).include?(filter.format)
next unless %w[html markdown_github].include?(filter.format)
next unless filter.doc.meta["insert_images"] && filter.doc.meta["insert_images"].value
next unless element.is_a?(PandocObjectFilters::Element::Header)
next unless element.elements.first.is_a?(PandocObjectFilters::Element::Str)
Expand Down
6 changes: 3 additions & 3 deletions rakelib/changelog.rake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Changelog
tags = `git tag -l`
return unless tags.include? Changelog.current_version
print "Are you updating the 'master' CHANGELOG? [yes/no] "
abort("Please update lib/gemstash/version.rb with the new version first!") unless STDIN.gets.strip.casecmp("yes") == 0
abort("Please update lib/gemstash/version.rb with the new version first!") unless STDIN.gets.strip.casecmp("yes").zero?
@master_update = true
end

Expand Down Expand Up @@ -85,7 +85,7 @@ class Changelog
puts "And store it at: #{token_path}"
puts "Otherwise you might hit rate limits while running this"
print "Continue without token? [yes/no] "
abort("Please create your token and retry") unless STDIN.gets.strip.casecmp("yes") == 0
abort("Please create your token and retry") unless STDIN.gets.strip.casecmp("yes").zero?
options = {}
end

Expand Down Expand Up @@ -248,7 +248,7 @@ class Changelog
def fetch_all_pull_requests
puts "Fetching all pull requests"
@pull_requests = octokit.pull_requests("bundler/gemstash", state: "all").
sort_by(&:number).map {|pr| PullRequest.new(pr) }
sort_by(&:number).map {|pr| PullRequest.new(pr) }
end

def reject_documented_pull_requests
Expand Down
16 changes: 8 additions & 8 deletions rakelib/doc.rake
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class Doc
end

def export_to_github
if base_file == "gemstash-readme.7.md"
path = doc.root_dir.join("README.md")
path = if base_file == "gemstash-readme.7.md"
doc.root_dir.join("README.md")
else
path = to_extension(".md")
to_extension(".md")
end

export "markdown_github", export_path("docs", path)
Expand All @@ -73,21 +73,21 @@ class Doc
end

def export_to_html
if base_file == "gemstash-readme.7.md"
path = "index.html"
path = if base_file == "gemstash-readme.7.md"
"index.html"
else
path = to_extension(".html")
to_extension(".html")
end

export "html", export_path("html", path)
end

def filters
%w(insert_github_generation_comment.rb
%w[insert_github_generation_comment.rb
insert_images.rb
upcase_headers.rb
fix_links_for_format.rb
fix_github_line_breaks.rb).map do |filter|
fix_github_line_breaks.rb].map do |filter|
::File.expand_path("../../rake/doc/#{filter}", __FILE__)
end
end
Expand Down
Loading

0 comments on commit 8409634

Please sign in to comment.