Skip to content

Improve compound name linting and idiomatic checks#809

Merged
yegor256 merged 7 commits intomasterfrom
806
Mar 29, 2026
Merged

Improve compound name linting and idiomatic checks#809
yegor256 merged 7 commits intomasterfrom
806

Conversation

@yegor256
Copy link
Copy Markdown
Member

@yegor256 yegor256 commented Mar 24, 2026

fixes #806

Summary by CodeRabbit

  • Bug Fixes
    • The compound-name linter now recognizes EO idiomatic names (prefixes as-, is-, and suffix -of) and no longer flags them as violations.
  • Documentation
    • Updated docs to explicitly permit as- conversion, is- predicate, and -of extractor naming patterns with examples.
  • Tests
    • Added lint tests to verify these idiomatic names produce no warnings.

Copilot AI review requested due to automatic review settings March 24, 2026 00:59
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 98437d86-20bf-4ba5-b508-0227e71819cb

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf073b and d6981d9.

📒 Files selected for processing (1)
  • src/main/resources/org/eolang/motives/names/compound-name.md
✅ Files skipped from review due to trivial changes (1)
  • src/main/resources/org/eolang/motives/names/compound-name.md

📝 Walkthrough

Walkthrough

The compound-name lint now exempts idiomatic EO naming patterns: names starting with as- or is-, and names ending with -of. A new eo:idiomatic() XSL function was added and integrated into the defect-selection XPath. Documentation and a test fixture were added.

Changes

Cohort / File(s) Summary
Core Linting Logic
src/main/resources/org/eolang/lints/names/compound-name.xsl
Added eo:idiomatic() XSL function to recognize as-*, is-* prefixes and -of suffix; updated XPath to require eo:compound(@name) and exclude eo:idiomatic(@name); minor punctuation fix.
Documentation
src/main/resources/org/eolang/motives/names/compound-name.md
Documented exceptions to the single-word rule for idiomatic as-, is-, and -of patterns with examples.
Test Coverage
src/test/resources/org/eolang/lints/packs/single/compound-name/allows-idiomatic-prefixes-and-suffixes.yaml
New YAML test verifying no warning-level defects for idiomatic compound names (e.g., as-bytes, is-empty, slice-of).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

core

Suggested reviewers

  • maxonfjvipon

Poem

🐰
Hopping through the files I see,
as- and is- now roam free.
-of joins the friendly crew,
No more false warnings—hip hop, woo! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Improve compound name linting and idiomatic checks' directly matches the main change: adding idiomatic name exemptions to compound-name linting to prevent false warnings.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #806: added eo:idiomatic() function recognizing as-, is- prefixes and -of suffix patterns, updated XPath to exclude idiomatic names, and included test coverage for these patterns.
Out of Scope Changes check ✅ Passed All changes are in-scope: updated linting XSL, documented idiomatic patterns, and added test coverage. No unrelated changes detected outside the stated objectives of improving compound-name linting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 806

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.


There are two exceptions for idiomatic prefixes used in EO standard library:
the `as-` prefix for type conversions (such as `as-bytes`, `as-i64`, `as-number`)
and the `is-` prefix for boolean predicates (such as `is-empty`, `is-nan`, `is-finite`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Vale.Spelling] Did you really mean 'boolean'?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the compound-name lint rule to allow idiomatic as- and is- prefixed names (common in EO stdlib), and documents/tests this exception.

Changes:

  • Added an XSL exception for names starting with as- and is- in the compound-name lint.
  • Added documentation describing the idiomatic prefix exceptions.
  • Added a YAML regression test ensuring these idiomatic names do not trigger warnings.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/test/resources/org/eolang/lints/packs/single/compound-name/allows-idiomatic-as-and-is-prefixes.yaml Adds a test case asserting no warnings for as-* / is-* names.
src/main/resources/org/eolang/motives/names/compound-name.md Documents the new idiomatic exceptions for compound names.
src/main/resources/org/eolang/lints/names/compound-name.xsl Implements the idiomatic-prefix exemption in the lint rule.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +22 to +28
<xsl:function name="eo:idiomatic" as="xs:boolean">
<xsl:param name="name"/>
<xsl:sequence select="starts-with($name, 'as-') or starts-with($name, 'is-')"/>
</xsl:function>
<xsl:template match="/">
<defects>
<xsl:for-each select="//o[@base and @name and not(eo:special(@name)) and eo:compound(@name)]">
<xsl:for-each select="//o[@base and @name and not(eo:special(@name)) and eo:compound(@name) and not(eo:idiomatic(@name))]">
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exemption is currently overly broad: any compound name starting with as- or is- bypasses the lint (e.g., as-very-long-compound-name), which undermines the rule and makes it easy to evade. Consider tightening eo:idiomatic($name) to only allow the intended idiomatic form (e.g., a single hyphen with a simple suffix via a regex like ^(as|is)-[a-z0-9]+$, or another clearly bounded pattern consistent with EO stdlib naming).

Copilot uses AI. Check for mistakes.
sheets:
- /org/eolang/lints/names/compound-name.xsl
asserts:
- /defects[count(defect[@severity='warning'])=0]
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion only guarantees there are no warning defects; the test could still pass if the lint emits defects with a different severity (e.g., error). If the intent is to ensure no defects at all for these names, consider asserting count(defect)=0 (or explicitly covering all severities expected in this lint pack) to make the regression test more robust.

Suggested change
- /defects[count(defect[@severity='warning'])=0]
- /defects[count(defect)=0]

Copilot uses AI. Check for mistakes.
read file
```

There are exceptions for idiomatic prefixes and suffixes used in EO standard library:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[Microsoft.SentenceLength] Try to keep sentences short (< 30 words).

@yegor256 yegor256 merged commit d59cc9e into master Mar 29, 2026
22 checks passed
@yegor256 yegor256 deleted the 806 branch March 29, 2026 11:57
@0crat
Copy link
Copy Markdown

0crat commented Mar 29, 2026

@yegor256 Great work on your contribution! 🎉 You've earned +4 points (+16 base, -8 for missing code review, -4 for 35 hits-of-code). Your running score is now +39! Please keep the momentum going and don't forget to check your Zerocracy account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compound-name lint incorrectly warns for idiomatic attribute names with as-* and is-* prefixes

3 participants