forked from covermymeds/rubocop-thread_safety
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7040b35
commit aff8cca
Showing
6 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'bundler/gem_tasks' | ||
require 'open3' | ||
|
||
require 'bundler' | ||
require 'bundler/gem_tasks' | ||
|
||
begin | ||
Bundler.setup(:default, :development) | ||
rescue Bundler::BundlerError => e | ||
warn e.message | ||
warn 'Run `bundle install` to install missing gems' | ||
exit e.status_code | ||
end | ||
|
||
require 'rspec/core/rake_task' | ||
require 'rubocop/rake_task' | ||
|
||
Dir['tasks/**/*.rake'].each { |t| load t } | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
RSpec::Core::RakeTask.new(:spec) do |spec| | ||
spec.pattern = FileList['spec/**/*_spec.rb'] | ||
end | ||
|
||
desc 'Run RuboCop over this gem' | ||
RuboCop::RakeTask.new(:internal_investigation) | ||
|
||
desc 'Confirm documentation is up to date' | ||
task confirm_documentation: :generate_cops_documentation do | ||
_, _, _, process = | ||
Open3.popen3('git diff --exit-code docs/') | ||
|
||
unless process.value.success? | ||
abort 'Please run `rake generate_cops_documentation` ' \ | ||
raise 'Please run `rake generate_cops_documentation` ' \ | ||
'and add docs/ to the commit.' | ||
end | ||
end | ||
|
||
task default: :spec | ||
task default: %i[spec | ||
internal_investigation | ||
documentation_syntax_check | ||
confirm_documentation] | ||
|
||
desc 'Generate a new cop template' | ||
task :new_cop, [:cop] do |_task, args| | ||
require 'rubocop' | ||
|
||
cop_name = args.fetch(:cop) do | ||
warn "usage: bundle exec rake 'new_cop[ThreadSafety/Name]'" | ||
exit! | ||
end | ||
|
||
generator = RuboCop::Cop::Generator.new(cop_name) | ||
|
||
generator.write_source | ||
generator.write_spec | ||
generator.inject_require(root_file_path: 'lib/rubocop-thread_safety.rb') | ||
generator.inject_config(config_file_path: 'config/default.yml') | ||
|
||
puts generator.todo | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: rubocop-thread_safety | ||
title: RuboCop Thread Safety | ||
version: ~ | ||
nav: | ||
- modules/ROOT/nav.adoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* xref:index.adoc[Home] | ||
* xref:installation.adoc[Installation] | ||
* xref:usage.adoc[Usage] | ||
* xref:cops.adoc[Cops] | ||
* Cops Documentation | ||
** xref:cops_threadsafety.adoc[thread_safety] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
= RuboCop Thread Safety | ||
|
||
Thread safety analysis for your projects, as an extension to | ||
https://github.com/rubocop/rubocop[RuboCop]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
= Installation | ||
|
||
Just install the `rubocop-thread_safety` gem | ||
|
||
[source,bash] | ||
---- | ||
gem install rubocop-thread_safety | ||
---- | ||
|
||
or if you use bundler put this in your `Gemfile` | ||
|
||
[source,ruby] | ||
---- | ||
gem 'rubocop-thread_safety' | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
= Usage | ||
|
||
You need to tell RuboCop to load the Thread Safety extension. There are three | ||
ways to do this: | ||
|
||
== RuboCop configuration file | ||
|
||
Put this into your `.rubocop.yml`. | ||
|
||
[source,yaml] | ||
---- | ||
require: rubocop-thread_safety | ||
---- | ||
|
||
Now you can run `rubocop` and it will automatically load the RuboCop Thread Safety | ||
cops together with the standard cops. | ||
|
||
== Command line | ||
|
||
[source,sh] | ||
---- | ||
$ rubocop --require rubocop-thread_safety | ||
---- | ||
|
||
== Rake task | ||
|
||
[source,ruby] | ||
---- | ||
RuboCop::RakeTask.new do |task| | ||
task.requires << 'rubocop-thread_safety' | ||
end | ||
---- |