rubocop-munra 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/README.md +11 -1
- data/config/default.yml +101 -1
- data/lib/rubocop/cop/munra/00_model_scope_names.rb +42 -0
- data/lib/rubocop/cop/munra/00_model_spec_section_checks.rb +71 -0
- data/lib/rubocop/cop/munra/00_rspec_helpers.rb +26 -3
- data/lib/rubocop/cop/munra/00_transaction_block_mixin.rb +7 -6
- data/lib/rubocop/cop/munra/address_fields_order.rb +66 -0
- data/lib/rubocop/cop/munra/address_state_select.rb +3 -3
- data/lib/rubocop/cop/munra/admin_policy.rb +55 -8
- data/lib/rubocop/cop/munra/brazilian_state_inclusion.rb +67 -0
- data/lib/rubocop/cop/munra/builtin_validation_options.rb +24 -6
- data/lib/rubocop/cop/munra/digits_only_attributes.rb +103 -0
- data/lib/rubocop/cop/munra/email_format.rb +21 -26
- data/lib/rubocop/cop/munra/flash_success_locale_name.rb +30 -25
- data/lib/rubocop/cop/munra/flash_success_name.rb +2 -2
- data/lib/rubocop/cop/munra/full_error_messages.rb +3 -6
- data/lib/rubocop/cop/munra/let_layout.rb +9 -2
- data/lib/rubocop/cop/munra/literal_expectation.rb +68 -0
- data/lib/rubocop/cop/munra/model_spec_structure.rb +156 -0
- data/lib/rubocop/cop/munra/named_subject_layout.rb +4 -6
- data/lib/rubocop/cop/munra/no_current_date_in_system_spec.rb +37 -0
- data/lib/rubocop/cop/munra/no_human_attribute_name.rb +1 -1
- data/lib/rubocop/cop/munra/no_inline_validation.rb +1 -1
- data/lib/rubocop/cop/munra/no_leading_dot.rb +1 -1
- data/lib/rubocop/cop/munra/no_mixed_example_siblings.rb +57 -0
- data/lib/rubocop/cop/munra/no_shared_examples.rb +9 -4
- data/lib/rubocop/cop/munra/one_example_per_context.rb +54 -0
- data/lib/rubocop/cop/munra/policy_blank_deny.rb +133 -0
- data/lib/rubocop/cop/munra/service_object.rb +14 -6
- data/lib/rubocop/cop/munra/validations_before_callbacks.rb +80 -0
- data/lib/rubocop/munra/plugin.rb +1 -1
- data/lib/rubocop/munra/version.rb +1 -3
- metadata +14 -19
- data/.github/workflows/ci.yml +0 -29
- data/.github/workflows/docs.yml +0 -90
- data/.ruby-version +0 -1
- data/AGENTS.md +0 -101
- data/CODE_OF_CONDUCT.md +0 -10
- data/Rakefile +0 -42
- data/antora-playbook.yml +0 -22
- data/docs/antora.yml +0 -5
- data/docs/modules/ROOT/nav.adoc +0 -5
- data/docs/modules/ROOT/pages/cops.adoc +0 -2
- data/docs/modules/ROOT/pages/cops_munra.adoc +0 -1026
- data/docs/modules/ROOT/pages/index.adoc +0 -11
- data/docs/modules/ROOT/pages/installation.adoc +0 -50
- data/docs/modules/ROOT/pages/usage.adoc +0 -98
- data/docs/usage.md +0 -29
- data/package-lock.json +0 -1930
- data/package.json +0 -12
- data/sig/rubocop/munra.rbs +0 -6
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
= RuboCop Munra
|
|
2
|
-
|
|
3
|
-
Custom https://docs.rubocop.org/rubocop/[RuboCop] cops (department `Munra`) for Rails application conventions used by Munra apps (the Munra product / codebase that consumes this gem).
|
|
4
|
-
|
|
5
|
-
Requires Ruby 3.2.0 or newer. Defaults live in this gem. Each app enables the plugin and overrides options in its own `.rubocop.yml`.
|
|
6
|
-
|
|
7
|
-
* xref:installation.adoc[Installation]
|
|
8
|
-
* xref:usage.adoc[Usage] — enable or disable cops, `Include` / `Exclude`, and option overrides
|
|
9
|
-
* xref:cops_munra.adoc[Munra cops] — per-cop reference (examples and configuration)
|
|
10
|
-
|
|
11
|
-
Source code: https://github.com/ramonsantos/rubocop-munra[ramonsantos/rubocop-munra].
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
= Installation
|
|
2
|
-
|
|
3
|
-
Add the gem to the application `Gemfile`.
|
|
4
|
-
|
|
5
|
-
From RubyGems:
|
|
6
|
-
|
|
7
|
-
[source,ruby]
|
|
8
|
-
----
|
|
9
|
-
gem 'rubocop-munra'
|
|
10
|
-
----
|
|
11
|
-
|
|
12
|
-
From a path checkout (local development):
|
|
13
|
-
|
|
14
|
-
[source,ruby]
|
|
15
|
-
----
|
|
16
|
-
gem 'rubocop-munra', path: '../../rubocop-munra'
|
|
17
|
-
----
|
|
18
|
-
|
|
19
|
-
From Git:
|
|
20
|
-
|
|
21
|
-
[source,ruby]
|
|
22
|
-
----
|
|
23
|
-
gem 'rubocop-munra', git: 'https://github.com/ramonsantos/rubocop-munra.git', branch: 'main'
|
|
24
|
-
----
|
|
25
|
-
|
|
26
|
-
Then:
|
|
27
|
-
|
|
28
|
-
[source,bash]
|
|
29
|
-
----
|
|
30
|
-
bundle install
|
|
31
|
-
----
|
|
32
|
-
|
|
33
|
-
Enable the plugin in the app's `.rubocop.yml`:
|
|
34
|
-
|
|
35
|
-
[source,yaml]
|
|
36
|
-
----
|
|
37
|
-
plugins:
|
|
38
|
-
- rubocop-munra
|
|
39
|
-
----
|
|
40
|
-
|
|
41
|
-
RuboCop loads `RuboCop::Munra::Plugin`, which points at this gem's `config/default.yml`. That file enables the `Munra` department and each cop's default options.
|
|
42
|
-
|
|
43
|
-
Check that the plugin is visible:
|
|
44
|
-
|
|
45
|
-
[source,bash]
|
|
46
|
-
----
|
|
47
|
-
bundle exec rubocop --show-cops Munra
|
|
48
|
-
----
|
|
49
|
-
|
|
50
|
-
See xref:usage.adoc[Usage] for department switches, path filters, and option overrides.
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
= Usage
|
|
2
|
-
|
|
3
|
-
`rubocop-munra` is a RuboCop plugin. It adds the `Munra` department: cops for Rails application conventions used by Munra apps. It runs on Ruby 3.2.0 and newer. Defaults live in this gem. Each app turns cops on or off and overrides options in its own `.rubocop.yml`. Do not copy cop source into the app.
|
|
4
|
-
|
|
5
|
-
== Enable the plugin
|
|
6
|
-
|
|
7
|
-
In the app's `.rubocop.yml`:
|
|
8
|
-
|
|
9
|
-
[source,yaml]
|
|
10
|
-
----
|
|
11
|
-
plugins:
|
|
12
|
-
- rubocop-munra
|
|
13
|
-
----
|
|
14
|
-
|
|
15
|
-
== Department and cop switches
|
|
16
|
-
|
|
17
|
-
Disable the whole department:
|
|
18
|
-
|
|
19
|
-
[source,yaml]
|
|
20
|
-
----
|
|
21
|
-
Munra:
|
|
22
|
-
Enabled: false
|
|
23
|
-
----
|
|
24
|
-
|
|
25
|
-
Disable one cop and keep the rest:
|
|
26
|
-
|
|
27
|
-
[source,yaml]
|
|
28
|
-
----
|
|
29
|
-
Munra/NoLeadingDot:
|
|
30
|
-
Enabled: false
|
|
31
|
-
----
|
|
32
|
-
|
|
33
|
-
Run a single cop while you adopt it:
|
|
34
|
-
|
|
35
|
-
[source,bash]
|
|
36
|
-
----
|
|
37
|
-
bundle exec rubocop --only Munra/NoLeadingDot
|
|
38
|
-
----
|
|
39
|
-
|
|
40
|
-
Ignore it in one file:
|
|
41
|
-
|
|
42
|
-
[source,ruby]
|
|
43
|
-
----
|
|
44
|
-
# rubocop:disable Munra/NoLeadingDot
|
|
45
|
-
chain
|
|
46
|
-
.call
|
|
47
|
-
# rubocop:enable Munra/NoLeadingDot
|
|
48
|
-
----
|
|
49
|
-
|
|
50
|
-
== Limit where a cop runs
|
|
51
|
-
|
|
52
|
-
Several cops ship with default `Include` paths (for example RSpec cops use `**/spec/**/*.rb`, admin policies use `app/policies/admin/**/*.rb`). `Include` and `Exclude` in the app are relative to the app, not to this gem.
|
|
53
|
-
|
|
54
|
-
[source,yaml]
|
|
55
|
-
----
|
|
56
|
-
Munra/NoLeadingDot:
|
|
57
|
-
Include:
|
|
58
|
-
- app/**/*.rb
|
|
59
|
-
Exclude:
|
|
60
|
-
- db/schema.rb
|
|
61
|
-
- vendor/**/*
|
|
62
|
-
----
|
|
63
|
-
|
|
64
|
-
`Include` replaces the cop's default include list when you set it. `Exclude` is merged with the default excludes. Prefer `Exclude` when you only want to skip a few paths.
|
|
65
|
-
|
|
66
|
-
== Override cop options
|
|
67
|
-
|
|
68
|
-
Domain values (attribute names, superclasses, allowed files) are keys in `config/default.yml`, not constants inside the cop. Override the keys you need. Omitted keys keep the gem default.
|
|
69
|
-
|
|
70
|
-
[source,yaml]
|
|
71
|
-
----
|
|
72
|
-
Munra/ServiceObject:
|
|
73
|
-
ExpectedSuffix: Service
|
|
74
|
-
ExpectedSuperclass: ApplicationService
|
|
75
|
-
RequirePrivateCall: true
|
|
76
|
-
----
|
|
77
|
-
|
|
78
|
-
[source,yaml]
|
|
79
|
-
----
|
|
80
|
-
Munra/AdminPolicy:
|
|
81
|
-
ExpectedSuperclass: Admin::ApplicationPolicy
|
|
82
|
-
ForbiddenMethods:
|
|
83
|
-
- new?
|
|
84
|
-
- edit?
|
|
85
|
-
----
|
|
86
|
-
|
|
87
|
-
The generated cop page lists every key, its type, and the default. Read xref:cops_munra.adoc[Munra cops] before inventing a key. Unknown keys are reported by RuboCop as configuration errors.
|
|
88
|
-
|
|
89
|
-
== Cop reference
|
|
90
|
-
|
|
91
|
-
Cop behavior is documented on the cop class (`@example` in the source) and generated into AsciiDoc. Regenerate after changing a cop comment or `config/default.yml`:
|
|
92
|
-
|
|
93
|
-
[source,bash]
|
|
94
|
-
----
|
|
95
|
-
bundle exec rake generate_cops_documentation
|
|
96
|
-
----
|
|
97
|
-
|
|
98
|
-
Do not edit `cops_munra.adoc` by hand. `DocumentationBaseURL` in `config/default.yml` is the prefix RuboCop uses for "see documentation" links; it points at this published site. `DocumentationExtension` is `.html`.
|
data/docs/usage.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Using rubocop-munra
|
|
2
|
-
|
|
3
|
-
Consumer documentation is published with Antora:
|
|
4
|
-
|
|
5
|
-
https://ramonsantos.github.io/rubocop-munra/
|
|
6
|
-
|
|
7
|
-
Edit these pages (not this file) when install or configuration guidance changes:
|
|
8
|
-
|
|
9
|
-
- [`docs/modules/ROOT/pages/installation.adoc`](modules/ROOT/pages/installation.adoc)
|
|
10
|
-
- [`docs/modules/ROOT/pages/usage.adoc`](modules/ROOT/pages/usage.adoc)
|
|
11
|
-
- [`docs/modules/ROOT/pages/index.adoc`](modules/ROOT/pages/index.adoc)
|
|
12
|
-
|
|
13
|
-
Per-cop reference is generated — do not hand-edit it:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
bundle exec rake generate_cops_documentation
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Develop this gem
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
bundle install
|
|
23
|
-
bundle exec rubocop
|
|
24
|
-
bundle exec rake test
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
`rake test` fails if line or branch coverage of `lib/` drops below 100%. `rake` runs the tests and RuboCop.
|
|
28
|
-
|
|
29
|
-
See [AGENTS.md](../AGENTS.md) for how new cops, tests, and docs are added.
|