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
data/AGENTS.md
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# AGENTS.md — rubocop-munra
|
|
2
|
-
|
|
3
|
-
RuboCop plugin (department `Munra`) consumed by Rails apps through Bundler (`path:`, `git:`, or RubyGems).
|
|
4
|
-
|
|
5
|
-
Write code, comments, docs, commit messages, issues, and pull requests in English.
|
|
6
|
-
|
|
7
|
-
## Git
|
|
8
|
-
|
|
9
|
-
Treat the session as **Orca** when the working tree path contains `/orca/workspaces/` or when `ORCA=1` is set in the environment. Otherwise treat it as a local (non-Orca) session.
|
|
10
|
-
|
|
11
|
-
### Inside Orca
|
|
12
|
-
|
|
13
|
-
Stage, commit, push, and open pull requests as the issue or task requires. Use English commit messages and PR bodies. A cop PR links the issue (`Closes #N`) and describes the cop, the config keys, and how to override them. Do not leave finished work unstaged or unpushed when the card asks for a PR.
|
|
14
|
-
|
|
15
|
-
### Outside Orca
|
|
16
|
-
|
|
17
|
-
Do not stage or commit. Never run `git add`, `git restore --staged`, `git rm`, or `git commit`. Leave every change unstaged in the working tree. The user reviews the diff locally and stages and commits it.
|
|
18
|
-
|
|
19
|
-
Do not push unless the user asks.
|
|
20
|
-
|
|
21
|
-
## Ruby
|
|
22
|
-
|
|
23
|
-
Develop on Ruby 3.2.0, the oldest version this gem supports. `.ruby-version` pins rbenv to that interpreter. Before running Bundler, RuboCop, or tests, `ruby -v` must report 3.2.0.
|
|
24
|
-
|
|
25
|
-
The published gem must run on every Ruby from 3.2.0 upward. Do not use syntax or standard-library behavior added after 3.2.0. Keep `required_ruby_version` at `>= 3.2.0` in the gemspec and `TargetRubyVersion: 3.2` in `.rubocop.yml`.
|
|
26
|
-
|
|
27
|
-
## Layout
|
|
28
|
-
|
|
29
|
-
| Piece | Where |
|
|
30
|
-
| --- | --- |
|
|
31
|
-
| Cop | `lib/rubocop/cop/munra/<snake_case>.rb` |
|
|
32
|
-
| Defaults / options | `config/default.yml` (`Munra/<CopName>`) |
|
|
33
|
-
| Cop test | `test/rubocop/cop/munra/<snake_case>_test.rb` (Minitest) |
|
|
34
|
-
| Other class test | `test/` path that mirrors `lib/`, one test class per implementation class |
|
|
35
|
-
| User guide | `docs/modules/ROOT/pages/` (`installation.adoc`, `usage.adoc`) |
|
|
36
|
-
| Generated cop reference | `docs/modules/ROOT/pages/cops_munra.adoc` |
|
|
37
|
-
|
|
38
|
-
`lib/rubocop/cop/munra.rb` `require`s every file in `munra/` in alphabetical order. Helpers use the `00_` prefix so they load before cops. Do not edit the loader when adding a cop.
|
|
39
|
-
|
|
40
|
-
Keep `Munra/<CopName>` entries in `config/default.yml` in alphabetical order by cop name. Whenever a cop is added or removed, leave the remaining declarations sorted among themselves.
|
|
41
|
-
|
|
42
|
-
The generated `docs/modules/ROOT/pages/cops_munra.adoc` must list cops in alphabetical order by name as well. After adding or removing a cop, regenerate the reference and confirm the sections stay sorted.
|
|
43
|
-
|
|
44
|
-
## After every change
|
|
45
|
-
|
|
46
|
-
Run both, and do not finish while either fails:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
bundle exec rubocop
|
|
50
|
-
bundle exec rake test
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
`rake test` starts SimpleCov. Line and branch coverage of `lib/**/*.rb` must stay at 100% for the run and for each file (`minimum_coverage` / `minimum_coverage_by_file` in `test/test_helper.rb`). Do not lower those thresholds to make a change pass. Cover the new paths instead.
|
|
54
|
-
|
|
55
|
-
`bundle exec rake` runs the test task and RuboCop.
|
|
56
|
-
|
|
57
|
-
## Tests
|
|
58
|
-
|
|
59
|
-
- Write examples with Minitest's spec DSL: `describe`, `context`, `let`, `subject`, and `it` (`test/test_helper.rb`). Do not add examples as `def test_*` methods. `context` groups a condition. `subject` is the object under test. `let` holds the other values an example needs.
|
|
60
|
-
- Do not leave a bare `it` as a sibling of a nested `describe` / `context`. Wrap that example in its own `context` (preferred) or `describe` so every `it` sits under a grouping block.
|
|
61
|
-
- Prefer `let` (and `subject`) over local variables inside `it` blocks. If a value is assigned and then used in assertions, move it to a `let` on the surrounding `describe` / `context`. Keep a local only when it cannot live in `let` (for example a path bound inside `Dir.mktmpdir`).
|
|
62
|
-
- One spec file per implementation class. A cop `Munra/NoLeadingDot` is specified in `test/rubocop/cop/munra/no_leading_dot_test.rb`. A mixin or plugin class gets its own file; do not fold several classes into one unrelated spec.
|
|
63
|
-
- Prefer unit tests that call the class directly. Build real AST with `parse_source` / `inspect_cop` (`test/test_helper.rb`) and real config objects. Also keep integration coverage for plugin loading and the default config file.
|
|
64
|
-
- Do not use mocks, stubs, or spies unless the dependency cannot be constructed in-process (network, clock, process). A small `Struct` for a LintRoller context is not a mock. Do not stub RuboCop, the file system, or the class under test.
|
|
65
|
-
- Assert the behavior of the implementation: offenses, config keys, and return values. Do not assert private call sequences.
|
|
66
|
-
- Within an `it`, keep comparable assertions in alphabetical order: constant paths by full namespace and class name, config dig keys and similar string identifiers by the key being asserted. Sort each homogeneous list among itself (for example department options together, then cop names together).
|
|
67
|
-
- Cop tests go through `inspect_cop`. Pass `cop_config` when the example depends on an override.
|
|
68
|
-
|
|
69
|
-
## Documentation
|
|
70
|
-
|
|
71
|
-
Document public classes, modules, and non-obvious methods with YARD comments in English (`@param`, `@return`, `@example` where a sample helps).
|
|
72
|
-
|
|
73
|
-
Cop classes need a prose description and `@example` blocks (`# bad` / `# good`) so RuboCop's documentation generator can render them. Domain constants (attribute names, superclasses, allowed files) belong in `config/default.yml` and are read with `cop_config`. Generic style or RSpec conventions may stay in code.
|
|
74
|
-
|
|
75
|
-
When a cop, its comment, or `config/default.yml` changes, regenerate the reference:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
bundle exec rake generate_cops_documentation
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Do not hand-edit `docs/modules/ROOT/pages/cops_munra.adoc` or `docs/modules/ROOT/pages/cops.adoc`. After `rake generate_cops_documentation`, the cop sections in `cops_munra.adoc` must remain in alphabetical order by cop name. Include the regenerated files in the same change set (commit them under Orca Git rules; leave them unstaged outside Orca).
|
|
82
|
-
|
|
83
|
-
Consumer guides are the Antora pages under `docs/modules/ROOT/pages/` (`installation.adoc`, `usage.adoc`, `index.adoc`). Update those when install or configuration behavior changes. Keep working examples of enabling the plugin, disabling a cop, `Include` / `Exclude`, and overriding real option keys (for example `Munra/ServiceObject`). `docs/usage.md` is only a pointer to the published site and contributor notes.
|
|
84
|
-
|
|
85
|
-
## New cop
|
|
86
|
-
|
|
87
|
-
1. Implement `lib/rubocop/cop/munra/<snake_case>.rb` with class docs and examples.
|
|
88
|
-
2. Register defaults under `Munra/<CopName>` in `config/default.yml`, inserted in alphabetical order among the other cops.
|
|
89
|
-
3. Add `test/rubocop/cop/munra/<snake_case>_test.rb` using the Minitest spec DSL rules above.
|
|
90
|
-
4. Update `test/rubocop/munra/load_test.rb`: assert the new constant and the `Munra/<CopName>` config dig, both in alphabetical order among the existing asserts.
|
|
91
|
-
5. Run RuboCop, the full test suite (100% coverage), and `rake generate_cops_documentation`. Confirm `cops_munra.adoc` sections stay alphabetical.
|
|
92
|
-
6. Follow the Git rules above (commit/push/PR in Orca; leave unstaged outside Orca).
|
|
93
|
-
7. In the consuming app, set only `Include`, `Exclude`, and overrides in `.rubocop.yml`. Do not copy the cop into the app.
|
|
94
|
-
|
|
95
|
-
## GitHub
|
|
96
|
-
|
|
97
|
-
Issues, pull requests, and review comments are in English. A cop pull request links the issue (`Closes #N`) and describes the cop, the config keys, and how to override them.
|
|
98
|
-
|
|
99
|
-
## Workspace
|
|
100
|
-
|
|
101
|
-
Tasks that touch cops and a consuming app should use a multi-root workspace (app + this gem).
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Code of Conduct
|
|
2
|
-
|
|
3
|
-
"rubocop-munra" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
|
|
4
|
-
|
|
5
|
-
* Participants will be tolerant of opposing views.
|
|
6
|
-
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
|
|
7
|
-
* When interpreting the words and actions of others, participants should always assume good intentions.
|
|
8
|
-
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
|
9
|
-
|
|
10
|
-
If you have any concerns about behaviour within this project, please contact us at ["ramonsantos.pe@gmail.com"](mailto:"ramonsantos.pe@gmail.com").
|
data/Rakefile
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'bundler/gem_tasks'
|
|
4
|
-
|
|
5
|
-
desc 'Run the Minitest suite with SimpleCov started before the tests'
|
|
6
|
-
task :test do
|
|
7
|
-
ruby '-Ilib:test -w test/suite.rb'
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
require 'rubocop/rake_task'
|
|
11
|
-
|
|
12
|
-
RuboCop::RakeTask.new
|
|
13
|
-
|
|
14
|
-
desc 'Generate AsciiDoc cop documentation from source comments and config/default.yml'
|
|
15
|
-
task :generate_cops_documentation do
|
|
16
|
-
require 'yard'
|
|
17
|
-
require 'rubocop'
|
|
18
|
-
require 'rubocop-munra'
|
|
19
|
-
require 'rubocop/cops_documentation_generator'
|
|
20
|
-
|
|
21
|
-
munra_cop_files = Dir[File.expand_path('lib/rubocop/cop/munra/*.rb', __dir__)]
|
|
22
|
-
generator = CopsDocumentationGenerator.new(
|
|
23
|
-
departments: %w[Munra],
|
|
24
|
-
plugin_name: 'rubocop-munra'
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
# `CopsDocumentationGenerator#call` only loads an existing `.yardoc` database.
|
|
28
|
-
# Parse Munra cop sources into the registry so class comments become AsciiDoc
|
|
29
|
-
# without requiring a separate `yard` run first.
|
|
30
|
-
generator.define_singleton_method(:call) do
|
|
31
|
-
YARD::Registry.load!
|
|
32
|
-
YARD.parse(munra_cop_files)
|
|
33
|
-
departments.each { |department| print_cops_of_department(department) }
|
|
34
|
-
print_table_of_contents
|
|
35
|
-
ensure
|
|
36
|
-
RuboCop::ConfigLoader.default_configuration = nil
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
generator.call
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
task default: %i[test rubocop]
|
data/antora-playbook.yml
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
site:
|
|
2
|
-
title: RuboCop Munra
|
|
3
|
-
url: https://ramonsantos.github.io/rubocop-munra
|
|
4
|
-
start_page: rubocop-munra::index.adoc
|
|
5
|
-
content:
|
|
6
|
-
sources:
|
|
7
|
-
- url: .
|
|
8
|
-
branches: HEAD
|
|
9
|
-
start_path: docs
|
|
10
|
-
ui:
|
|
11
|
-
bundle:
|
|
12
|
-
url: https://gitlab.com/antora/antora-ui-default/-/jobs/artifacts/HEAD/raw/build/ui-bundle.zip?job=bundle-stable
|
|
13
|
-
snapshot: true
|
|
14
|
-
supplemental_files:
|
|
15
|
-
- path: ui.yml
|
|
16
|
-
contents: |
|
|
17
|
-
static_files:
|
|
18
|
-
- .nojekyll
|
|
19
|
-
- path: .nojekyll
|
|
20
|
-
contents: ''
|
|
21
|
-
output:
|
|
22
|
-
dir: build/site
|
data/docs/antora.yml
DELETED
data/docs/modules/ROOT/nav.adoc
DELETED