Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.rbc
.bundle
.config
.envrc
.yardoc
Gemfile.lock
InstalledFiles
Expand Down
2 changes: 1 addition & 1 deletion lib/tty/commands/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def add_license_to_gemspec(license)
else
gem_license = " " * gemspec.pre_var_indent
gem_license << "#{gemspec.var_name}.license"
gem_license << " " * (gemspec.post_var_indent - ".license".size)
gem_license << " " * [(gemspec.post_var_indent - ".license".size), 0].max
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance/FixedSize: Do not compute the size of statically sized objects.
Metrics/LineLength: Line is too long. [83/80]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gem_license << " " * [(gemspec.post_var_indent - ".license".size), 0].max
gem_license << " " * [(gemspec.post_var_indent - ".license".size), 1].max

Using 0 as the minimum would produce spec.license= "MIT" (no space before =), which is inconsistent with the format bundler generates for other attributes (e.g. spec.name = "sandbox"). A minimum of 1 ensures the output matches the surrounding style.

Image

gem_license << "= \"#{licenses[license][:name]}\""
gemspec.content.gsub!(/(^\s*#{gemspec.var_name}\.name\s*=\s*.*$)/,
"\\1\n#{gem_license}")
Expand Down