mirror of
https://github.com/elastic/logstash.git
synced 2025-04-17 19:35:03 -04:00
Add basic ruby linter (#15168)
Adds rubocop as a linter for ruby.: - Adds .rubocop.yml which defines specific config on top of default - Adds Gradle task 'lint' task - Adds 'lint:report' rake task to report Lint Cops. - Adds 'lint:format' rake task to automatically format the code.
This commit is contained in:
parent
07b663561c
commit
6154a69c15
5 changed files with 269 additions and 0 deletions
220
.rubocop.yml
Normal file
220
.rubocop.yml
Normal file
|
@ -0,0 +1,220 @@
|
|||
AllCops:
|
||||
RubyInterpreters:
|
||||
- ruby
|
||||
- rake
|
||||
- jruby
|
||||
Include:
|
||||
- '**/*.rb'
|
||||
- '**/*.gemfile'
|
||||
- '**/*.gemspec'
|
||||
- '**/*.rake'
|
||||
- '**/Gemfile'
|
||||
- '**/Rakefile'
|
||||
Exclude:
|
||||
- 'node_modules/**/*'
|
||||
- 'tmp/**/*'
|
||||
- 'vendor/**/*'
|
||||
- '.git/**/*'
|
||||
- 'build/**/*'
|
||||
- 'config/**/*'
|
||||
DisplayCopNames: true
|
||||
UseCache: false
|
||||
#################### Layout ###########################
|
||||
Layout/AccessModifierIndentation:
|
||||
Enabled: false
|
||||
Layout/ArgumentAlignment:
|
||||
Enabled: false
|
||||
Layout/ArrayAlignment:
|
||||
Enabled: false
|
||||
Layout/AssignmentIndentation:
|
||||
Enabled: false
|
||||
Layout/BeginEndAlignment:
|
||||
Enabled: false
|
||||
Layout/BlockAlignment:
|
||||
Enabled: false
|
||||
Layout/BlockEndNewline:
|
||||
Enabled: false
|
||||
Layout/CaseIndentation:
|
||||
Enabled: false
|
||||
Layout/ClassStructure:
|
||||
Enabled: false
|
||||
Layout/ClosingHeredocIndentation:
|
||||
Enabled: false
|
||||
Layout/ClosingParenthesisIndentation:
|
||||
Enabled: false
|
||||
Layout/CommentIndentation:
|
||||
Enabled: false
|
||||
Layout/ConditionPosition:
|
||||
Enabled: false
|
||||
Layout/DefEndAlignment:
|
||||
Enabled: false
|
||||
Layout/DotPosition:
|
||||
Enabled: false
|
||||
Layout/ElseAlignment:
|
||||
Enabled: false
|
||||
Layout/EmptyComment:
|
||||
Enabled: false
|
||||
Layout/EmptyLineAfterGuardClause:
|
||||
Enabled: false
|
||||
Layout/EmptyLineAfterMagicComment:
|
||||
Enabled: false
|
||||
Layout/EmptyLineAfterMultilineCondition:
|
||||
Enabled: false
|
||||
Layout/EmptyLineBetweenDefs:
|
||||
Enabled: false
|
||||
Layout/EmptyLines:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundAccessModifier:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundArguments:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundAttributeAccessor:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundBeginBody:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundBlockBody:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundClassBody:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundExceptionHandlingKeywords:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundMethodBody:
|
||||
Enabled: false
|
||||
Layout/EmptyLinesAroundModuleBody:
|
||||
Enabled: false
|
||||
Layout/EndAlignment:
|
||||
Enabled: false
|
||||
Layout/EndOfLine:
|
||||
Enabled: false
|
||||
Layout/ExtraSpacing:
|
||||
Enabled: false
|
||||
Layout/FirstArgumentIndentation:
|
||||
Enabled: false
|
||||
Layout/FirstArrayElementIndentation:
|
||||
Enabled: false
|
||||
Layout/FirstArrayElementLineBreak:
|
||||
Enabled: false
|
||||
Layout/FirstHashElementIndentation:
|
||||
Enabled: false
|
||||
Layout/FirstHashElementLineBreak:
|
||||
Enabled: false
|
||||
Layout/FirstMethodArgumentLineBreak:
|
||||
Enabled: false
|
||||
Layout/FirstMethodParameterLineBreak:
|
||||
Enabled: false
|
||||
Layout/FirstParameterIndentation:
|
||||
Enabled: false
|
||||
Layout/HashAlignment:
|
||||
Enabled: false
|
||||
Layout/HeredocArgumentClosingParenthesis:
|
||||
Enabled: false
|
||||
Layout/HeredocIndentation:
|
||||
Enabled: false
|
||||
Layout/IndentationConsistency:
|
||||
Enabled: false
|
||||
Layout/IndentationStyle:
|
||||
Enabled: false
|
||||
Layout/IndentationWidth:
|
||||
Enabled: false
|
||||
Layout/InitialIndentation:
|
||||
Enabled: false
|
||||
Layout/LeadingCommentSpace:
|
||||
Enabled: false
|
||||
Layout/LeadingEmptyLines:
|
||||
Enabled: false
|
||||
Layout/LineContinuationLeadingSpace:
|
||||
Enabled: false
|
||||
Layout/LineContinuationSpacing:
|
||||
Enabled: false
|
||||
Layout/LineEndStringConcatenationIndentation:
|
||||
Enabled: false
|
||||
Layout/LineLength:
|
||||
Enabled: false
|
||||
Layout/MultilineArrayBraceLayout:
|
||||
Enabled: false
|
||||
Layout/MultilineArrayLineBreaks:
|
||||
Enabled: false
|
||||
Layout/MultilineAssignmentLayout:
|
||||
Enabled: false
|
||||
Layout/MultilineBlockLayout:
|
||||
Enabled: false
|
||||
Layout/MultilineHashBraceLayout:
|
||||
Enabled: false
|
||||
Layout/MultilineHashKeyLineBreaks:
|
||||
Enabled: false
|
||||
Layout/MultilineMethodArgumentLineBreaks:
|
||||
Enabled: false
|
||||
Layout/MultilineMethodCallBraceLayout:
|
||||
Enabled: false
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
Enabled: false
|
||||
Layout/MultilineMethodDefinitionBraceLayout:
|
||||
Enabled: false
|
||||
Layout/MultilineMethodParameterLineBreaks:
|
||||
Enabled: false
|
||||
Layout/MultilineOperationIndentation:
|
||||
Enabled: false
|
||||
Layout/ParameterAlignment:
|
||||
Enabled: false
|
||||
Layout/RedundantLineBreak:
|
||||
Enabled: false
|
||||
Layout/RescueEnsureAlignment:
|
||||
Enabled: false
|
||||
Layout/SingleLineBlockChain:
|
||||
Enabled: false
|
||||
Layout/SpaceAfterColon:
|
||||
Enabled: false
|
||||
Layout/SpaceAfterComma:
|
||||
Enabled: false
|
||||
Layout/SpaceAfterMethodName:
|
||||
Enabled: false
|
||||
Layout/SpaceAfterNot:
|
||||
Enabled: false
|
||||
Layout/SpaceAfterSemicolon:
|
||||
Enabled: false
|
||||
Layout/SpaceAroundBlockParameters:
|
||||
Enabled: false
|
||||
Layout/SpaceAroundEqualsInParameterDefault:
|
||||
Enabled: false
|
||||
Layout/SpaceAroundKeyword:
|
||||
Enabled: false
|
||||
Layout/SpaceAroundMethodCallOperator:
|
||||
Enabled: false
|
||||
Layout/SpaceAroundOperators:
|
||||
Enabled: false
|
||||
Layout/SpaceBeforeBlockBraces:
|
||||
Enabled: false
|
||||
Layout/SpaceBeforeBrackets:
|
||||
Enabled: false
|
||||
Layout/SpaceBeforeComma:
|
||||
Enabled: false
|
||||
Layout/SpaceBeforeComment:
|
||||
Enabled: false
|
||||
Layout/SpaceBeforeFirstArg:
|
||||
Enabled: false
|
||||
Layout/SpaceBeforeSemicolon:
|
||||
Enabled: false
|
||||
Layout/SpaceInLambdaLiteral:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideArrayLiteralBrackets:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideArrayPercentLiteral:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideBlockBraces:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideHashLiteralBraces:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideParens:
|
||||
Enabled: false
|
||||
Layout/SpaceInsidePercentLiteralDelimiters:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideRangeLiteral:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideReferenceBrackets:
|
||||
Enabled: false
|
||||
Layout/SpaceInsideStringInterpolation:
|
||||
Enabled: false
|
||||
Layout/TrailingEmptyLines:
|
||||
Enabled: false
|
||||
Layout/TrailingWhitespace:
|
||||
Enabled: false
|
|
@ -20,6 +20,7 @@ gem "octokit", "~> 4.25", :group => :build
|
|||
gem "rubyzip", "~> 1", :group => :build
|
||||
gem "stud", "~> 0.0.22", :group => :build
|
||||
|
||||
gem "rubocop", :group => :development
|
||||
gem "belzebuth", :group => :development
|
||||
gem "benchmark-ips", :group => :development
|
||||
gem "ci_reporter_rspec", "~> 1", :group => :development
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -34,5 +34,7 @@ Developing?
|
|||
`rake test:install-core` installs any dependencies for testing Logstash core
|
||||
`rake test:core` to run Logstash core tests
|
||||
`rake vendor:clean` clean vendored dependencies used for Logstash development
|
||||
`rake lint:report` to run the Rubocop linter
|
||||
`rake lint:format` to automatically format the code
|
||||
HELP
|
||||
end
|
||||
|
|
|
@ -739,6 +739,14 @@ class JDKDetails {
|
|||
}
|
||||
}
|
||||
|
||||
tasks.register("lint") {
|
||||
// Calls rake's 'lint' task
|
||||
dependsOn installDevelopmentGems
|
||||
doLast {
|
||||
rake(projectDir, buildDir, 'lint:report')
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("downloadJdk", Download) {
|
||||
// CLI project properties: -Pjdk_bundle_os=[windows|linux|darwin] -Pjdk_arch=[arm64|x86_64]
|
||||
|
||||
|
|
38
rakelib/lint.rake
Normal file
38
rakelib/lint.rake
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Licensed to Elasticsearch B.V. under one or more contributor
|
||||
# license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright
|
||||
# ownership. Elasticsearch B.V. licenses this file to you under
|
||||
# the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
namespace "lint" do
|
||||
|
||||
module RuboCLI
|
||||
def self.run!(*args)
|
||||
require "rubocop"
|
||||
cli = RuboCop::CLI.new
|
||||
result = cli.run(["--force-exclusion", *args])
|
||||
raise "Linting failed." if result.nonzero?
|
||||
end
|
||||
end
|
||||
|
||||
# task that runs lint report
|
||||
task "report" do
|
||||
RuboCLI.run!("--lint")
|
||||
end
|
||||
|
||||
# task that automatically fixes code formatting
|
||||
task "format" do
|
||||
RuboCLI.run!("--fix-layout")
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue