diff --git a/share/linters/.rubocop.yml b/share/linters/.rubocop.yml new file mode 100644 index 0000000000..df43d7fef9 --- /dev/null +++ b/share/linters/.rubocop.yml @@ -0,0 +1,178 @@ +# +# Configuration file for rubocop linter +# Applies to every ruby file on the OpenNebula repository +# + + +######## +# LAYOUT +######## + +# Check indendation +Layout/IndentationWidth: + Width: 4 + +# no space before block paramenter {|var| code } +Layout/SpaceInsideBlockBraces: + SpaceBeforeBlockParameters: false + +# X indentation raw & method call +Layout/IndentArray: + EnforcedStyle: consistent + +Layout/IndentHash: + EnforcedStyle: consistent +### + +# Align the end keyword +Layout/EndAlignment: + AutoCorrect: true + +# empty line after X declaration and before X end: +Layout/EmptyLinesAroundClassBody: + EnforcedStyle: empty_lines + +Layout/EmptyLinesAroundModuleBody: + EnforcedStyle: empty_lines +### + +####### +# STYLE +####### + +Style/StringLiterals: + EnforcedStyle: single_quotes + +Style/SignalException: + EnforcedStyle: only_raise + +Style/BracesAroundHashParameters: + EnforcedStyle: braces + +Style/ConditionalAssignment: + EnforcedStyle: assign_inside_condition + +# No parentheses with no argument +Style/DefWithParentheses: + Enabled: true + +# Simple loop does not require each +Style/EachForSimpleLoop: + Enabled: false + +# empty elses must be omitted +Style/EmptyElse: + EnforcedStyle: empty + +# use for instead of each +Style/For: + EnforcedStyle: for + +# it's mandatory to left a empty line before guard clause +Style/EmptyLineAfterGuardClause: + Enabled: true + +# declare key, value pairs with => +Style/HashSyntax: + EnforcedStyle: hash_rockets + +# You can put if blocks inside if +Style/IfInsideElse: + Enabled: false + +# one line if/unless conditions +Style/IfUnlessModifier: + Enabled: true + +# Mandatory use of Parentheses in method calls +Style/MethodCallWithArgsParentheses: + Enabled: false + +# Use unless in one line statement +Style/NegatedIf: + EnforcedStyle: postfix + +# better tu use next instead of if +Style/Next: + EnforcedStyle: skip_modifier_ifs + +# not use _ in numbers +Style/NumericLiterals: + Enabled: false + +# optional parameters always at the end +Style/OptionalArguments: + Enabled: true + +# return nil not allowed +Style/ReturnNil: + Enabled: true + +# use rescue splitted in lines +Style/RescueModifier: + Enabled: false + +Style/MutableConstant: + Enabled: false + +###### +# LINT +###### + +# check calls to pry +Lint/Debugger: + Enabled: true + +# check duplicate X: +Lint/DuplicateCaseCondition: + Enabled: true + +Lint/DuplicateMethods: + Enabled: true + +Lint/DuplicatedKey: + Enabled: true +## + +# check empty exceptions +Lint/HandleExceptions: + Enabled: true + +# check matching parameters in format +Lint/FormatParameterMismatch: + Enabled: true + +## else as block +Lint/ElseLayout: + Enabled: true + +# Check for shadowed parameters inside a block +Lint/ShadowingOuterLocalVariable: + Enabled: true + + +######### +# METRICS +######## + +# Line Length config: +Metrics/LineLength: + Max: 100 + +# Parameter list config: +Metrics/ParameterLists: + Max: 5 + CountKeywordArgs: true + + +# uppercase constant mandatory +Naming/ConstantName: + Enabled: true + +### +# Bundler +#### + +# order alphabetically deactivated +Bundler/OrderedGems: + Enabled: false