Giter VIP home page Giter VIP logo

pessimize's People

Contributors

andyobtiva avatar arthurhess avatar bsedat avatar deepak avatar joemsak avatar joonty avatar mariozig avatar randallreedjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pessimize's Issues

Running pessimize after fresh install, undefined method `[]' for nil:NilClass

Hello

I'm unable to use the gem suddenly. Please let me know if I am missing something, or what I should inspect? Thanks!

[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Backing up Gemfile and Gemfile.lock
 + cp Gemfile Gemfile.backup
 + cp Gemfile.lock Gemfile.lock.backup

Traceback (most recent call last):
        13: from /Users/joemsak/.asdf/installs/ruby/2.6.5/bin/pessimize:23:in `<main>'
        12: from /Users/joemsak/.asdf/installs/ruby/2.6.5/bin/pessimize:23:in `load'
        11: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/bin/pessimize:5:in `<top (required)>'
        10: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/shell.rb:15:in `run'
         9: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/pessimizer.rb:14:in `run'
         8: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/pessimizer.rb:28:in `collect_gems_and_versions'
         7: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/pessimizer.rb:28:in `new'
         6: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:13:in `initialize'
         5: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:27:in `parse_gems_from_tokens!'
         4: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:27:in `loop'
         3: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:37:in `block in parse_gems_from_tokens!'
         2: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:37:in `new'
         1: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gem.rb:9:in `initialize'
/Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gem.rb:52:in `parse_version': undefined method `[]' for nil:NilClass (NoMethodError)
kadenzeweb develop % ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]```

No newline between some statements in output

Before pessimize...

ruby "1.9.3"

if RUBY_VERSION =~ /1.9/
  Encoding.default_external = Encoding::UTF_8
  Encoding.default_internal = Encoding::UTF_8
end

source 'http://rubygems.org'
source 'http://gems.github.com'

gem 'rails', '3.0.20'

...after...

ruby "1.9.3"source "http://rubygems.org"source "http://gems.github.com"

gem "rails", "~> 3.0.20"

trollop no longer supported

Upon installing the gem I get the following:

$ gem install pessimize
Fetching: trollop-2.9.9.gem (100%)
!    The 'trollop' gem has been deprecated and has been replaced by 'optimist'.
!    See: https://rubygems.org/gems/optimist
!    And: https://github.com/ManageIQ/optimist
Successfully installed trollop-2.9.9
Fetching: pessimize-0.4.0.gem (100%)
Successfully installed pessimize-0.4.0
Parsing documentation for trollop-2.9.9
Installing ri documentation for trollop-2.9.9
Parsing documentation for pessimize-0.4.0
Installing ri documentation for pessimize-0.4.0
Done installing documentation for trollop, pessimize after 0 seconds
2 gems installed

And when I run the command, I get:

$ pessimize --no-backup
[DEPRECATION] This gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
~> written 94 gems to Gemfile, constrained to minor version updates

I figured you might want to know :)

Feature idea: take the more pessimistic version

Feature idea: Support an option to take the more pessimistic version:

Given a gem pinned to a patch version
When I run pessimize -c minor
The more pessimistic patch version is kept in the Gemfile

Maybe it should be a Bundler plugin?

You can write your own bundler plugins instead of invoking gem.
did you consider that ?
more info:
https://bundler.io/guides/bundler_plugins.html

I also think about those bundle update switches:

--minor
Prefer updating only to next minor version.

--major
Prefer updating to next major version (default).

--strict
Do not allow any gem to be updated past latest --patch | --minor | --major.

--conservative
Use bundle install conservative update behavior and do not allow indirect dependencies to be updated.

Option to unpessimize

Feature Request: How about adding an option to unpessimize i.e. remove version specification from Gemfile?

This is useful in case when you want to update old Gemfile and running bundle update instead of removing the version restrictions manully.

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec,

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Even for projects that already specify a license, including a license in your gemspec is a good practice, since it is easily
discoverable there without having to check the readme or for a license file. For example, it is the field that rubygems.org uses to display a gem's license.

For example, there is a License Finder gem to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough
issue that even Bundler now generates gems with a default 'MIT' license.

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), github has created a license picker tool.

In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :).

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue and let me know. In either case, I'll follow up. Thanks!

p.s. I've written a blog post about this project

Multiple group block separating into individual groups

Hope this helps some what! Just a though and what I expected from the result.
When I have:

group :production, :staging, :live_dev do
  gem 'newrelic_rpm'
  gem 'rails_12factor'
  gem 'heroku-deflater'
end

What I get after running pessimize

group :production do
  gem 'newrelic_rpm', '~> 3.12'
  gem 'rails_12factor', '~> 0.0'
  gem 'heroku-deflater', '~> 0.5'
end

group :staging do
  gem 'newrelic_rpm', '~> 3.12'
  gem 'rails_12factor', '~> 0.0'
  gem 'heroku-deflater', '~> 0.5'
end

group :live_dev do
  gem 'newrelic_rpm', '~> 3.12'
  gem 'rails_12factor', '~> 0.0'
  gem 'heroku-deflater', '~> 0.5'
end

This will cause the following errors to appear on any bundle command and will repeat for each group stage.

Your Gemfile lists the gem newrelic_rpm (~> 3.12) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem rails_12factor (~> 0.0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem heroku-deflater (~> 0.5) more than once.
You should probably keep only one of them.

What I expect

group :production, :staging, :live_dev do
  gem 'newrelic_rpm', '~> 3.12'
  gem 'rails_12factor', '~> 0.0'
  gem 'heroku-deflater', '~> 0.5'
end

Correctly handle `beta` and `pre` gems

If a gem version is in beta or pre (the final part of the version can be any string, I think), pessimize doesn't currently work correctly. For example, the debugger2 gem has version "1.0.0.beta2", but using the constraint "~> 1.0" doesn't seem to include beta gems.

There are two ways round this:

  1. Don't add constraints to beta/pre gems, i.e. gem "debugger2"
  2. Specify the exact version for beta/pre gems, i.e. gem "debugger2", "1.0.0.beta2"

I'm leaning towards 1, as it's not ideal to lock down a gem version to always be in beta.

Downgrades my gems

I'm a bit disappointed by the results from executing this gem (trying all possible settings)

image

So it takes rspec 3 and turns it into rspec 0.1. Umm...

Dunno if it's a parsing issue or an algorithm issue.

The algo should be dead-simple and it should absolutely not try to be smart:

  • Take versions from Gemfile.lock
  • Copy the numbers literally to the Gemfile (up to minor or patch level, depending on command-line options)

What do you think it happened?

Cheers - Victor

Use an actual ruby parser to parse the Gemfile

Currently, only methods and their arguments are retained in a Gemfile, as it is evaluated using instance_eval. If there are any extra statements (such as conditionals), they will not be kept.

This could be fixed by actually parsing the file with Ripper, or something similar.

Multiple sources in gemfile.

When there are two sources:

source "https://rubygems.org"
source "http://myothersource.com"

Pessimizing the project results in those both being re-output to the same line.

source "http://myothersource.com"source "https://rubygems.org"

This will result in a Gemfile syntax error.

They need to be each on their own line, as in the first example.

Support inline comments

No pessimistic constraint operators are added for lines of the Gemfile which have an inline comment e.g.
gem 'spring' # Rails application preloader

Strange Behaviour

Problems:

Before:

gem "seedbank", "~> 0.3.0.pre"
gem "high_voltage"

After:

gem "seedbank", '0.2'
gem "high_voltage" # Still no version

Argument list error

/Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/dsl.rb:9:in instance_eval': wrong number of arguments (2 for 1) (ArgumentError) from (eval):62:inparse'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/dsl.rb:9:in instance_eval' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/dsl.rb:9:inparse'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/pessimizer.rb:28:in collect_gems_and_versions' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/pessimizer.rb:15:inrun'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/shell.rb:12:in run' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/bin/pessimize:5:in<top (required)>'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/pessimize:19:in load' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/pessimize:19:in

'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/ruby_noexec_wrapper:14:in eval' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/ruby_noexec_wrapper:14:in'

Parser stops after comment

We use comments to label gems in our Gemfile (sometimes the use of a gem doesn't come easily from the name ๐Ÿ˜„) and this seems to stop the Pessimize parser from labeling subsequent gem lines. I've attached a sample Gemfile (and the Gemfile.backup) that triggers the issue. If I remove the ruby comment everything seems to work great.

Gemfile (after running pessimize):

# A sample Gemfile
source "https://rubygems.org"

gem "rails", "~> 4.2"
gem "pessimize", "~> 0.3" # Breaks here
gem "devise"

Gemfile.backup:

# A sample Gemfile
source "https://rubygems.org"

gem "rails"
gem "pessimize" # Breaks here
gem "devise"

rake spec fails

Cloning this project, bundling, and running rake fails:

WARN -- :       This usage of the Code Climate Test Reporter is now deprecated. Since version
      1.0, we now require you to run `SimpleCov` in your test/spec helper, and then
      run the provided `codeclimate-test-reporter` binary separately to report your
      results to Code Climate.

      More information here: https://github.com/codeclimate/ruby-test-reporter/blob/master/README.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.