Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ on:
# Run every on Friday to ensure everything works as expected.
- cron: '0 6 * * 5'
jobs:
CI:
lint:
runs-on: ubuntu-latest
container:
image: zammad/zammad-ci:latest
steps:
- uses: actions/checkout@v6
- name: Run lint actions
shell: bash
run: |
source /etc/profile.d/rvm.sh # ensure RVM is loaded
bundle update --bundler
bundle install -j $(nproc)
bundle exec rubocop
test:
runs-on: ubuntu-latest
container:
image: zammad/zammad-ci:latest
Expand Down
206 changes: 66 additions & 140 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# Default enabled cops
# https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml

plugins:
- rubocop-performance
- rubocop-rake
- rubocop-rspec

inherit_from:
- .rubocop_todo.yml

AllCops:
NewCops: enable
Exclude:
- 'bin/rails'
- 'bin/rake'
- 'bin/spring'
- 'db/schema.rb'

Rails:
Enabled: true
- 'examples/**/*'

# Zammad StyleGuide

Metrics/LineLength:
Description: 'Limit lines to 80 characters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
Style/FrozenStringLiteralComment:
Enabled: false

Style/NegatedIf:
Expand All @@ -32,81 +37,70 @@ Style/IfUnlessModifier:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
Enabled: false

Style/TrailingCommaInLiteral:
Description: 'Checks for trailing comma in array and hash literals.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Style/TrailingCommaInArrayLiteral:
Description: 'Checks for trailing comma in array literals.'
StyleGuide: '#no-trailing-array-commas'
Enabled: false

Style/TrailingCommaInHashLiteral:
Description: 'Checks for trailing comma in hash literals.'
Enabled: false

Style/TrailingCommaInArguments:
Description: 'Checks for trailing comma in argument lists.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
Enabled: false

Style/SpaceInsideParens:
Description: 'No spaces after ( or before ).'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces'
Enabled: false

Style/SpaceAfterMethodName:
Description: >-
Do not put a space between a method name and the opening
parenthesis in a method definition.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
Enabled: false

Style/LeadingCommentSpace:
Layout/LeadingCommentSpace:
Description: 'Comments should start with a space.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'
Enabled: false

Style/MethodCallParentheses:
Description: 'Do not use parentheses for method calls with no arguments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
Enabled: false
Layout/HashAlignment:
Description: >-
Align the elements of a hash literal if they span more than
one line.
Enabled: true
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
EnforcedLastArgumentHashStyle: always_inspect

Style/SpaceInsideBrackets:
Description: 'No spaces after [ or before ].'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces'
Style/ClassAndModuleChildren:
Description: 'Checks style of children classes and modules.'
Enabled: false

Style/DefWithParentheses:
Description: 'Use def with parentheses when there are arguments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
Enabled: false
Style/MethodDefParentheses:
Naming/MethodParameterName:
Description: >-
Checks if the method definitions have or don't have
parentheses.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
Enabled: false
Checks for method parameter names that contain capital letters,
end in numbers, or do not meet a minimal length.
Enabled: true
AllowedNames: [id]

Style/EmptyLinesAroundClassBody:
Description: "Keeps track of empty lines around class bodies."
Enabled: false
Layout/MultilineMethodCallIndentation:
Description: >-
Checks the indentation of the method name part in method calls
that span more than one line.
EnforcedStyle: indented

Style/EmptyLinesAroundMethodBody:
Description: "Keeps track of empty lines around method bodies."
Enabled: false
Style/RescueStandardError:
EnforcedStyle: implicit

Style/EmptyLinesAroundBlockBody:
Description: "Keeps track of empty lines around block bodies."
Style/Documentation:
Enabled: false

Style/EmptyLinesAroundModuleBody:
Description: "Keeps track of empty lines around module bodies."
Style/PerlBackrefs:
Description: 'Avoid Perl-style regex back references.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
Enabled: false

Style/BlockDelimiters:
Description: >-
Avoid using {...} for multi-line blocks (multiline chaining is
always ugly).
Prefer {...} over do...end for single-line blocks.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
Style/BlockComments:
# Keep block comments (=begin ... =end) to allow for easy copy-pasting of examples.
Description: 'Do not use block comments.'
Enabled: false

Style/MultilineBlockChain:
Description: 'Avoid multi-line chains of blocks.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
Layout/LineLength:
Description: 'Limit lines to 80 characters.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
Enabled: false

Metrics/ClassLength:
Expand All @@ -118,98 +112,30 @@ Metrics/MethodLength:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
Enabled: false

Style/BlockComments:
Description: 'Do not use block comments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-block-comments'
Enabled: false

Style/PerlBackrefs:
Description: 'Avoid Perl-style regex back references.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
Enabled: false

Style/SelfAssignment:
Description: >-
Checks for places where self-assignment shorthand should have
been used.
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
Enabled: false

Style/BracesAroundHashParameters:
Description: 'Enforce braces style around hash parameters.'
Enabled: false

Rails/FindEach:
Description: 'Prefer all.find_each over all.find.'
Enabled: false

Rails/HasAndBelongsToMany:
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
# StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
Enabled: false

Style/ClassAndModuleChildren:
Description: 'Checks style of children classes and modules.'
Enabled: false

Style/FileName:
Description: 'Use snake_case for source file names.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
Enabled: true
Exclude:
- 'script/websocket-server.rb'


# 2.0

Metrics/PerceivedComplexity:
Description: >-
A complexity metric geared towards measuring complexity for a
human reader.
Enabled: false

Metrics/AbcSize:
Description: >-
A calculated magnitude based on number of assignments,
branches, and conditions.
Enabled: false
Max: 34

Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: false

Metrics/BlockNesting:
Description: 'Avoid excessive block nesting'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
Enabled: false
Max: 12

Metrics/ModuleLength:
Description: 'Avoid modules longer than 100 lines of code.'
Enabled: false

# TODO

Style/Documentation:
Description: 'Document classes and non-namespace modules.'
Enabled: false
Metrics/PerceivedComplexity:
Max: 12

Lint/UselessAssignment:
Enabled: false
RSpec/ExampleLength:
inherit_mode:
merge:
- Exclude
CountAsOne:
- 'array'
- 'hash'
- 'heredoc'
Max: 25

Style/ExtraSpacing:
Description: 'Do not use unnecessary spacing.'
Enabled: false
RSpec/NestedGroups:
Max: 6

# Broken!!!! Generates broken code since "String".downcase == "strinG".downcase is not equals "String".casecmp("strinG") but "String".casecmp("strinG") == 0 !!!
Performance/Casecmp:
Description: 'Use `casecmp` rather than `downcase ==`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
Enabled: false

# Disabled since we want that explicitly
Style/MethodMissing:
Description: 'Avoid using `method_missing`.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-method-missing'
Enabled: false
47 changes: 47 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Gemspec/RequiredRubyVersion:
Enabled: false

Gemspec/RequireMFA:
Enabled: false

Gemspec/AddRuntimeDependency:
Enabled: false

Gemspec/DevelopmentDependencies:
Enabled: false

Naming/PredicateMethod:
Enabled: false

Style/MissingRespondToMissing:
Enabled: false

Style/StringConcatenation:
Enabled: false

Naming/AccessorMethodName:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/ExampleLength:
Enabled: false

RSpec/SpecFilePathFormat:
Enabled: false

RSpec/NoExpectationExample:
Enabled: false

RSpec/DescribeMethod:
Enabled: false

RSpec/ContextWording:
Enabled: false

RSpec/BeforeAfterAll:
Enabled: false

RSpec/LeakyLocalVariable:
Enabled: false
Loading