ruby-changes:62224
From: Utkarsh <ko1@a...>
Date: Wed, 15 Jul 2020 16:05:40 +0900 (JST)
Subject: [ruby-changes:62224] 3b0d2a3d6d (master): [rubygems/rubygems] Fix RuboCop offenses
https://git.ruby-lang.org/ruby.git/commit/?id=3b0d2a3d6d From 3b0d2a3d6ddd4f3d361e15af96881275e8923a5e Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta <utkarsh@d...> Date: Fri, 19 Jun 2020 16:14:18 +0530 Subject: [rubygems/rubygems] Fix RuboCop offenses These offenses appear when you create a gem with `bundle gem foo` and run `rubocop` over it. Initially, there were around 45 offenses detected, but with #3731 and this, the number of offenses have been reduced to 2. Signed-off-by: Utkarsh Gupta <utkarsh@d...> https://github.com/rubygems/rubygems/commit/fe9dcaa1b4 diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt index b689e2e..c6af5e8 100644 --- a/lib/bundler/templates/newgem/Gemfile.tt +++ b/lib/bundler/templates/newgem/Gemfile.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/Gemfile.tt#L1 +# frozen_string_literal: true + source "https://rubygems.org" # Specify your gem's dependencies in <%= config[:name] %>.gemspec diff --git a/lib/bundler/templates/newgem/Rakefile.tt b/lib/bundler/templates/newgem/Rakefile.tt index af7729c..46bb01c 100644 --- a/lib/bundler/templates/newgem/Rakefile.tt +++ b/lib/bundler/templates/newgem/Rakefile.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/Rakefile.tt#L1 +# frozen_string_literal: true + require "bundler/gem_tasks" <% default_task_names = [config[:test_task]].compact -%> <% case config[:test] -%> @@ -27,7 +29,7 @@ RuboCop::RakeTask.new https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/Rakefile.tt#L29 <% default_task_names.unshift(:clobber, :compile) -%> require "rake/extensiontask" -task :build => :compile +task build: :compile Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext| ext.lib_dir = "lib/<%= config[:namespaced_path] %>" diff --git a/lib/bundler/templates/newgem/bin/console.tt b/lib/bundler/templates/newgem/bin/console.tt index a27f824..6378a5a 100644 --- a/lib/bundler/templates/newgem/bin/console.tt +++ b/lib/bundler/templates/newgem/bin/console.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/bin/console.tt#L1 +# frozen_string_literal: true + #!/usr/bin/env ruby require "bundler/setup" diff --git a/lib/bundler/templates/newgem/lib/newgem.rb.tt b/lib/bundler/templates/newgem/lib/newgem.rb.tt index fae6337..a182b96 100644 --- a/lib/bundler/templates/newgem/lib/newgem.rb.tt +++ b/lib/bundler/templates/newgem/lib/newgem.rb.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/lib/newgem.rb.tt#L1 +# frozen_string_literal: true + require "<%= config[:namespaced_path] %>/version" <%- if config[:ext] -%> require "<%= config[:namespaced_path] %>/<%= config[:underscored_name] %>" diff --git a/lib/bundler/templates/newgem/lib/newgem/version.rb.tt b/lib/bundler/templates/newgem/lib/newgem/version.rb.tt index 389daf5..b5cd4cb 100644 --- a/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +++ b/lib/bundler/templates/newgem/lib/newgem/version.rb.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/lib/newgem/version.rb.tt#L1 +# frozen_string_literal: true + <%- config[:constant_array].each_with_index do |c, i| -%> <%= " " * i %>module <%= c %> <%- end -%> diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt index 7961ccf..948de2d 100644 --- a/lib/bundler/templates/newgem/newgem.gemspec.tt +++ b/lib/bundler/templates/newgem/newgem.gemspec.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/newgem.gemspec.tt#L1 +# frozen_string_literal: true + require_relative "lib/<%=config[:namespaced_path]%>/version" Gem::Specification.new do |spec| @@ -6,8 +8,8 @@ Gem::Specification.new do |spec| https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/newgem.gemspec.tt#L8 spec.authors = [<%= config[:author].inspect %>] spec.email = [<%= config[:email].inspect %>] - spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.} - spec.description = %q{TODO: Write a longer description or delete this line.} + spec.summary = "TODO: Write a short summary, because RubyGems requires one." + spec.description = "TODO: Write a longer description or delete this line." spec.homepage = "TODO: Put your gem's website or public repo URL here." <%- if config[:mit] -%> spec.license = "MIT" @@ -22,9 +24,7 @@ Gem::Specification.new do |spec| https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/newgem.gemspec.tt#L24 # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do - `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - end + spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] diff --git a/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt b/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt index c63b487..82cada9 100644 --- a/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +++ b/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt#L1 +# frozen_string_literal: true + RSpec.describe <%= config[:constant_name] %> do it "has a version number" do expect(<%= config[:constant_name] %>::VERSION).not_to be nil diff --git a/lib/bundler/templates/newgem/spec/spec_helper.rb.tt b/lib/bundler/templates/newgem/spec/spec_helper.rb.tt index 805cf57..0bb8e6f 100644 --- a/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +++ b/lib/bundler/templates/newgem/spec/spec_helper.rb.tt @@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/newgem/spec/spec_helper.rb.tt#L1 +# frozen_string_literal: true + require "bundler/setup" require "<%= config[:namespaced_path] %>" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/