Coder Social home page Coder Social logo

rubocop-extension-generator's Introduction

RuboCop Logo


Ruby Style Guide Gem Version CircleCI Status Actions Status Test Coverage Maintainability Discord

Role models are important.
-- Officer Alex J. Murphy / RoboCop

RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.

RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options.


Patreon OpenCollective OpenCollective Tidelift

Working on RuboCop is often fun, but it also requires a great deal of time and energy.

Please consider financially supporting its ongoing development.

Installation

RuboCop's installation is pretty standard:

$ gem install rubocop

If you'd rather install RuboCop using bundler, add a line for it in your Gemfile (but set the require option to false, as it is a standalone tool):

gem 'rubocop', require: false

RuboCop is stable between minor versions, both in terms of API and cop configuration. We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop releases. All big changes are reserved for major releases. To prevent an unwanted RuboCop update you might want to use a conservative version lock in your Gemfile:

gem 'rubocop', '~> 1.63', require: false

See our versioning policy for further details.

Quickstart

Just type rubocop in a Ruby project's folder and watch the magic happen.

$ cd my/cool/ruby/project
$ rubocop

You can also use this magic in your favorite editor with RuboCop's built-in LSP server.

Documentation

You can read a lot more about RuboCop in its official docs.

Compatibility

RuboCop officially supports the following runtime Ruby implementations:

  • MRI 2.7+
  • JRuby 9.4+

Targets Ruby 2.0+ code analysis.

See the compatibility documentation for further details.

Readme Badge

If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.

Ruby Style Guide

Ruby Style Guide

Here are the Markdown snippets for the two badges:

[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)

[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)

Team

Here's a list of RuboCop's core developers:

See the team page for more details.

Logo

RuboCop's logo was created by Dimiter Petrov. You can find the logo in various formats here.

The logo is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Contributors

Here's a list of all the people who have contributed to the development of RuboCop.

I'm extremely grateful to each and every one of them!

If you'd like to contribute to RuboCop, please take the time to go through our short contribution guidelines.

Converting more of the Ruby Style Guide into RuboCop cops is our top priority right now. Writing a new cop is a great way to dive into RuboCop!

Of course, bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! :-)

Funding

While RuboCop is free software and will always be, the project would benefit immensely from some funding. Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project which would speed up the pace of development significantly.

We welcome both individual and corporate sponsors! We also offer a wide array of funding channels to account for your preferences (although currently Open Collective is our preferred funding platform).

If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company to become a RuboCop sponsor.

You can support the development of RuboCop via GitHub Sponsors, Patreon, PayPal, Open Collective and Tidelift .

Note: If doing a sponsorship in the form of donation is problematic for your company from an accounting standpoint, we'd recommend the use of Tidelift, where you can get a support-like subscription instead.

Open Collective Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Open Collective Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Changelog

RuboCop's changelog is available here.

Copyright

Copyright (c) 2012-2024 Bozhidar Batsov. See LICENSE.txt for further details.

rubocop-extension-generator's People

Contributors

koic avatar maxh avatar nobuyo avatar pocke avatar sambostock avatar sue445 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rubocop-extension-generator's Issues

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

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

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

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.