Coder Social home page Coder Social logo

rubocop-extension-generator's Issues

Generator crashing because README.md format that bundler generates has been changed

I'm not sure when exactly this started, but if using a newer version of bundler, the expected gem <name> in the README.md generated when the gem is initialized is missing, and always crashes.

https://github.com/rubocop/rubocop-extension-generator/blob/master/lib/rubocop/extension/generator/generator.rb#L140

Here is a README.md generated with bundle gem sample command.

# Sample

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sample`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

## Installation

Install the gem and add to the application's Gemfile by executing:

    $ bundle add sample

If bundler is not being used to manage dependencies, install the gem by executing:

    $ gem install sample

## Usage

TODO: Write usage instructions here

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sample.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Error log:

~/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-extension-generator-0.4.0/lib/rubocop/extension/generator/generator.rb:162:in `patch': Cannot apply patch for rubocop-develop/README.md because (?-mix:^gem 'rubocop-develop'$) is missing (RuntimeError)
	from ~/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-extension-generator-0.4.0/lib/rubocop/extension/generator/generator.rb:140:in `generate'
	from ~/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-extension-generator-0.4.0/lib/rubocop/extension/generator/cli.rb:29:in `run'
	from ~/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-extension-generator-0.4.0/lib/rubocop/extension/generator/cli.rb:12:in `run'
	from ~/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/rubocop-extension-generator-0.4.0/exe/rubocop-extension-generator:5:in `<top (required)>'
	from ~/.rbenv/versions/3.1.2/bin/rubocop-extension-generator:25:in `load'
	from ~/.rbenv/versions/3.1.2/bin/rubocop-extension-generator:25:in `<main>'

Versions:

$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]

$ bundler --version
Bundler version 2.3.12

$ rubocop-extension-generator --version
rubocop-extension-generator 0.4.0

Bug Report: Invalid module name

Actual behavior

I run the command:

$ rubocop-extension-generator rubocop-foobar

And I got the following files:

# rubocop-foobar/sig/rubocop/foobar.rbs

module Rubocop
  module Foobar
    VERSION: String
    # See the writing guide of rbs: https://github.com/ruby/rbs#guides
  end
end
# rubocop-foobar/spec/rubocop/foobar_spec.rb

module Rubocop
  module Foobar
    VERSION: String
    # See the writing guide of rbs: https://github.com/ruby/rbs#guides
  end
end

Then I run rspec:

ydakuka@yauhenid:~/Work/rubocop-foobar$ rspec spec/

An error occurred while loading ./spec/rubocop/foobar_spec.rb.
Failure/Error:
  RSpec.describe Rubocop::Foobar do
    it "has a version number" do
      expect(Rubocop::Foobar::VERSION).not_to be nil
    end
  
    it "does something useful" do
      expect(false).to eq(true)
    end
  end

NameError:
  uninitialized constant Rubocop
  Did you mean?  RuboCop
# ./spec/rubocop/foobar_spec.rb:3:in `<top (required)>'
No examples found.

Finished in 0.00002 seconds (files took 0.69338 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

Expected behavior

Rubocop -> RuboCop

RuboCop version

ydakuka@yauhenid:~/Work/rubocop-foobar$ rubocop -V
1.51.0 (using Parser 3.2.2.1, rubocop-ast 1.28.1, running on ruby 2.7.6) [x86_64-linux]

ydakuka@yauhenid:~/Work/rubocop-foobar$ rubocop-extension-generator -v
rubocop-extension-generator 0.5.2

Duplication of gem 'rspec'

The Gemfile generated by bundle gem may already contain the gem 'rspec'. (This depends on BUNDLE_GEM__TEST)

In that case, the following error will occur:

[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: rspec (~> 3.0) and rspec (>= 0). Bundler cannot continue.

 #  from /path/to/Gemfile:13
 #  -------------------------------------------
 #  gem "rubocop", "~> 1.21"
 >  gem 'rspec'
 #  -------------------------------------------

patch 'Gemfile', /\z/, <<~RUBY
gem 'rspec'
RUBY

I think the expected behavior is not to add it if gem 'rspec', ... is already included.

Generated cop refers to a dead link

I've generated a new project using extension generator. Then I generated a cop using bundle exec rake new_cop[Domain/Cop]

It generated a file lib/rubocop/cop/domain/cop.rb and it had those lines:

      class Cop < Base
        # TODO: Implement the cop in here.
        #
        # In many cases, you can use a node matcher for matching node pattern.
        # See https://github.com/rubocop-hq/rubocop-ast/blob/master/lib/rubocop/node_pattern.rb
        #
        # For example

However, the link https://github.com/rubocop-hq/rubocop-ast/blob/master/lib/rubocop/node_pattern.rb returns 404

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.