Skip to content

Commit 2fc6857

Browse files
committed
Include standard.rb tool
1 parent 58c14c9 commit 2fc6857

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

doc_generation/rubocop_doc/generator.rb

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#!/usr/bin/env ruby
22

33
# Plugins with patterns documentation should be added here
4-
$plugins = ["rubocop-performance",
5-
"rubocop-rails",
6-
"rubocop-sorbet",
7-
"rubocop-graphql",
8-
"rubocop-thread_safety",
9-
"rubocop-minitest",
10-
"rubocop-rake",
11-
"rubocop-rspec",
12-
"rubocop-i18n",
13-
"rubocop-faker",
14-
"rubocop-factory_bot",
15-
"rubocop-md",
16-
"rubocop-mdsol",
17-
"rubocop-rspec_rails",
18-
"rubocop-capybara",
19-
"rubocop-rubycw"
20-
]
4+
$plugins = %w[rubocop-performance
5+
rubocop-rails
6+
rubocop-sorbet
7+
rubocop-graphql
8+
rubocop-thread_safety
9+
rubocop-minitest
10+
rubocop-rake
11+
rubocop-rspec
12+
rubocop-i18n
13+
rubocop-faker
14+
rubocop-factory_bot
15+
rubocop-md
16+
rubocop-mdsol
17+
rubocop-rspec_rails
18+
rubocop-capybara
19+
rubocop-rubycw
20+
standard]
2121

2222
# frozen_string_literal: true
2323
require 'rubocop'
@@ -39,12 +39,12 @@ def initialize(cop, config)
3939

4040
# Reverses what this method does: RuboCop::Config#make_excludes_absolute
4141
def make_excludes_relative(config, base_dir)
42-
config["Exclude"]&.map! do |exclude_elem|
42+
config['Exclude']&.map! do |exclude_elem|
4343
if exclude_elem.is_a?(String)
4444
exclude_path = Pathname.new(exclude_elem)
4545
base_dri = Pathname.new(base_dir)
4646

47-
if base_dri.relative?() != exclude_path.relative?()
47+
if base_dri.relative? != exclude_path.relative?
4848
exclude_elem
4949
else
5050
exclude_path.relative_path_from(base_dri).to_s
@@ -77,24 +77,28 @@ def configurable_attributes
7777

7878
def yard_object
7979
return @yard_object if @yard_object
80+
8081
result = nil
8182

8283
YARD::Registry.all(:class).detect do |code_object|
8384
next unless RuboCop::Cop::Badge.for(code_object.to_s) == cop.badge
85+
8486
result = code_object
8587
end
8688
@yard_object = result
8789
end
8890

8991
def description
9092
return '' unless yard_object
93+
9194
yard_object.docstring.to_s
9295
end
9396

9497
def examples_description
9598
return '' unless yard_object
9699
return '' if yard_object.tags('example').empty?
97-
result = "```ruby\n".dup
100+
101+
result = +"```ruby\n"
98102
yard_object.tags('example').map do |x|
99103
result << x.text
100104
end
@@ -104,12 +108,12 @@ def examples_description
104108

105109
def as_json
106110
{
107-
name: name,
108-
department_name: department_name,
109-
description: description,
110-
examples_description: examples_description,
111-
configuration: configuration,
112-
configurable_attributes: configurable_attributes,
111+
name:,
112+
department_name:,
113+
description:,
114+
examples_description:,
115+
configuration:,
116+
configurable_attributes:
113117
}
114118
end
115119
end
@@ -122,7 +126,8 @@ def self.rubocop_source_code_path(plugin_with_version)
122126
end
123127

124128
def self.run
125-
blacklist = ["Lint/RedundantCopDisableDirective", "Sorbet/SignatureCop", "GraphQL/OrderedArguments", "GraphQL/OrderedFields"]
129+
blacklist = ['Lint/RedundantCopDisableDirective', 'Sorbet/SignatureCop', 'GraphQL/OrderedArguments',
130+
'GraphQL/OrderedFields']
126131

127132
# Each plugin has a Version, so we retrieve that to know where to look on the gem files for the Cops documentation
128133
plugins_with_versions = $plugins.map do |plugin|
@@ -133,9 +138,9 @@ def self.run
133138
# Add rubocop itself as a source of Cops
134139
plugins_with_versions << "rubocop-#{RuboCop::Version::STRING}"
135140

136-
puts "Generating documentation based on Rubocop and plugins:"
141+
puts 'Generating documentation based on Rubocop and plugins:'
137142
puts plugins_with_versions
138-
puts "^^^^ MAKE SURE THE PLUGIN YOU ADDED IS ON THE LIST ABOVE, OTHERWISE WILL NOT BE PART OF THE patterns.json"
143+
puts '^^^^ MAKE SURE THE PLUGIN YOU ADDED IS ON THE LIST ABOVE, OTHERWISE WILL NOT BE PART OF THE patterns.json'
139144

140145
YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
141146
task.files = plugins_with_versions.map(&method(:rubocop_source_code_path))
@@ -149,6 +154,7 @@ def self.run
149154
result = []
150155
cops.each do |cop|
151156
next if blacklist.include? cop.cop_name
157+
152158
result << RubocopDocs::CopDoc.new(cop, config)
153159
end
154160
result = result.map(&:as_json)

src/main/scala/codacy/rubocop/Rubocop.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ object Rubocop extends Tool {
3232
"rubocop-md",
3333
"rubocop-mdsol",
3434
"rubocop-rspec_rails",
35-
"rubocop-capybara"
35+
"rubocop-capybara",
36+
"standard"
3637
)
3738

3839
// Gemfile is analysed

0 commit comments

Comments
 (0)