Skip to content

Commit 8175d23

Browse files
JOYclaude
andcommitted
Merge upstream blockscout/blockscout master
Sync 61 commits from upstream. Resolved 67 conflicts: - Deleted workflow files (modify/delete): keep deleted (DOScan custom CI) - mix.exs versions: accept upstream - Elixir source: accept upstream - CHANGELOG.md: accept upstream Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 parents f544084 + fecacf7 commit 8175d23

197 files changed

Lines changed: 8909 additions & 2853 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
File renamed without changes.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
name: alphabetically-ordered-aliases
3+
description: Ensure that aliases are alphabetically ordered within their groups to maintain consistent code style and address Credo readability warnings.
4+
---
5+
6+
## Overview
7+
8+
Elixir code style conventions prefer that module aliases are alphabetically ordered within their groups. This improves code readability, maintainability, and consistency. Credo checks for this ordering and warns when aliases are not properly alphabetized.
9+
10+
## When to Use
11+
12+
- When addressing Credo warning: "The alias is not alphabetically ordered among its group"
13+
- When organizing module aliases at the top of a file
14+
- When multiple aliases from related modules are defined together
15+
- When refactoring code to improve consistency and readability
16+
17+
## Anti-Patterns (Avoid These)
18+
19+
```elixir
20+
defmodule Explorer.Migrator.HeavyDbIndexOperation.RenameTransactions do
21+
# ❌ BAD: Aliases not alphabetically ordered
22+
alias Explorer.Chain.Cache.BackgroundMigrations
23+
alias Explorer.Migrator.{HeavyDbIndexOperation, MigrationStatus}
24+
alias Explorer.Migrator.HeavyDbIndexOperation.Helper
25+
alias Explorer.Migrator.HeavyDbIndexOperation.DropTransactionsIndex
26+
alias Explorer.Repo
27+
end
28+
29+
# In the above, "Helper" comes after "DropTransactionsIndex"
30+
# alphabetically, but it's listed before it. Correct order should be:
31+
# - DropTransactionsIndex (D < H)
32+
# - Helper (H)
33+
```
34+
35+
## Best Practices (Use These)
36+
37+
```elixir
38+
defmodule Explorer.Migrator.HeavyDbIndexOperation.RenameTransactions do
39+
# ✅ GOOD: Aliases properly alphabetically ordered
40+
alias Explorer.Chain.Cache.BackgroundMigrations
41+
alias Explorer.Migrator.{HeavyDbIndexOperation, MigrationStatus}
42+
43+
# Within same group, ordered alphabetically:
44+
# D comes before H comes before R
45+
alias Explorer.Migrator.HeavyDbIndexOperation.DropTransactionsIndex
46+
alias Explorer.Migrator.HeavyDbIndexOperation.Helper
47+
alias Explorer.Repo
48+
end
49+
```
50+
51+
## How to Implement
52+
53+
### Step 1: Identify alias groups
54+
Aliases are grouped by their module depth and prefix. List all aliases by location:
55+
56+
```
57+
Group 1: Single-level modules
58+
- alias Explorer.Repo
59+
60+
Group 2: Multi-level modules from same prefix
61+
- alias Explorer.Chain.Cache.BackgroundMigrations
62+
- alias Explorer.Migrator...
63+
```
64+
65+
### Step 2: Sort alphabetically within each group
66+
67+
Within each group, sort by:
68+
1. The full module path alphabetically
69+
2. Consider the last component of the path when the prefix is the same
70+
71+
For modules with the same prefix like:
72+
- `Explorer.Migrator.HeavyDbIndexOperation.CreateTransactions...`
73+
- `Explorer.Migrator.HeavyDbIndexOperation.DropTransactions...`
74+
- `Explorer.Migrator.HeavyDbIndexOperation.Helper`
75+
76+
Sort by the last component: `Create...` < `Drop...` < `Helper`
77+
78+
### Step 3: Reorder in code
79+
80+
Rearrange the alias statements to match the alphabetical order determined in Step 2.
81+
82+
### Step 4: Verify with Credo
83+
84+
Run Credo to ensure no warnings remain:
85+
86+
```bash
87+
mix credo --strict
88+
```
89+
90+
## Example Violations and Fixes
91+
92+
### Violation 1: Helper before DropTransactions
93+
94+
```elixir
95+
# ❌ BEFORE
96+
alias Explorer.Migrator.HeavyDbIndexOperation.Helper
97+
alias Explorer.Migrator.HeavyDbIndexOperation.DropTransactionsIndex
98+
99+
# ✅ AFTER
100+
alias Explorer.Migrator.HeavyDbIndexOperation.DropTransactionsIndex
101+
alias Explorer.Migrator.HeavyDbIndexOperation.Helper
102+
```
103+
104+
### Violation 2: Mixed ordering in group
105+
106+
```elixir
107+
# ❌ BEFORE
108+
alias Explorer.Repo
109+
alias Explorer.Chain.Cache.BackgroundMigrations
110+
alias Explorer.Migrator.{HeavyDbIndexOperation, MigrationStatus}
111+
112+
# ✅ AFTER
113+
alias Explorer.Chain.Cache.BackgroundMigrations
114+
alias Explorer.Migrator.{HeavyDbIndexOperation, MigrationStatus}
115+
alias Explorer.Repo
116+
```
117+
118+
## Related Skills
119+
120+
- [Code Formatting](../code-formatting/SKILL.md) - Run after applying alias ordering fixes
121+
- [Alias Nested Modules](../alias-nested-modules/SKILL.md) - Define aliases for nested modules
122+
123+
## References
124+
125+
- [Credo Readability.AliasOrder](https://hexdocs.pm/credo/Credo.Check.Readability.AliasOrder.html)
126+
- [Elixir Naming Conventions](https://hexdocs.pm/elixir/naming-conventions.html)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: code-formatting
3-
description: Fixes code formatting in the Blockscout Elixir project using mix format. Use when you need to fix formatting violations, code style inconsistencies, or ensure consistent code formatting. For linting issues, use `mix credo`.
3+
description: Fixes code formatting in the Blockscout Elixir project using mix format. Use when you need to fix formatting violations, code style inconsistencies, or ensure consistent code formatting. For linting issues, use `mix credo`. Use this skill for every change made.
44
---
55

66
## Overview
File renamed without changes.
File renamed without changes.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
name: elixir-credo-predicate-naming
3+
description: "Use when working on Elixir code with Credo predicate naming warnings, boolean helper functions, or renaming functions that start with is_. Prevents violations like: Predicate function names should not start with 'is' and should end in a question mark."
4+
---
5+
6+
# Elixir Credo Predicate Naming
7+
8+
Use this skill to prevent and fix predicate naming violations in Elixir.
9+
10+
## Rules
11+
12+
- Predicate functions must end with `?`.
13+
- Predicate functions must not start with `is_`.
14+
- Prefer names like `valid_*?`, `enabled_*?`, `has_*?`, `can_*?`, `matches_*?`, or `<noun>_*?`.
15+
16+
## Refactor Workflow
17+
18+
1. Find predicate functions named like `is_*?`.
19+
2. Rename each one to a Credo-compliant name that still reads clearly.
20+
3. Update all call sites in the same module and across the codebase.
21+
4. Keep arity unchanged unless behavior intentionally changes.
22+
5. Run a focused Credo check for edited files.
23+
24+
## Naming Guidance
25+
26+
- `is_valid_zrc2_transfer_log?/4` -> `valid_zrc2_transfer_log?/4`
27+
- `is_enabled?/1` -> `enabled?/1`
28+
- `is_erc20_transfer?/2` -> `erc20_transfer?/2`
29+
- `is_contract_verified?/1` -> `contract_verified?/1`
30+
31+
## Safety Checks
32+
33+
- Preserve semantics during rename.
34+
- Verify no stale references remain.
35+
- If the function is part of a public API, rename consistently and update docs/specs.
36+
37+
## Verification Commands
38+
39+
```bash
40+
mix credo path/to/file.ex
41+
mix test
42+
```
43+
44+
## Expected Result
45+
46+
No Credo findings for predicate naming in updated files.

0 commit comments

Comments
 (0)