Skip to content

Apply Offler 1.0.1 formatting fixes: move else to same line#507

Open
cchantep wants to merge 1 commit intoReactiveMongo:masterfrom
cchantep:task/scalafix
Open

Apply Offler 1.0.1 formatting fixes: move else to same line#507
cchantep wants to merge 1 commit intoReactiveMongo:masterfrom
cchantep:task/scalafix

Conversation

@cchantep
Copy link
Copy Markdown
Member

Remove OfflerGoodCodeSyntax.ignore suppression - now using fixed Offler 1.0.1

Update MacroImpl.scala: Add OfflerGoodCodeSemantic to scalafix:off suppression

This suppression prevents two specific Offler issues:

  1. OfflerGoodCodeSyntax would apply formatting changes to complex macro code
  2. OfflerGoodCodeSemantic would remove the type annotation from macroCfgInit, which is required by the override contract for non-volatile type compatibility.

The scalafix:off comment is placed before the package declaration to ensure it applies to the entire file and suppresses both Offler rules.

Fix: Apply Offler formatting and structurally prevent type annotation removal

Changes made:

  1. Removed scalafix:off workaround from MacroImpl.scala header
  2. Applied Offler-recommended formatting fixes:
    • Convert postfix notation to dot notation (c.typecheck -> c typecheck)
    • Move else to same line as closing brace
    • Apply similar formatting throughout the file
  3. Fixed macroCfgInit to prevent unwanted type annotation removal:
    • Wrapped body in braces: q{...} -> { q{...} }
    • Makes body non-trivial so Offler's rule doesn't remove required type annotation
    • The type annotation is required for override contract compliance

The actual root cause was that Offler's DefWithTypeTrivalBodyExtractor was treating the quasiquote body as trivial and removing the type annotation. Wrapping in braces makes it a block expression (non-trivial), preventing the removal while preserving semantics.

Pull Request Checklist

Fixes

Fixes #xxxx

Purpose

What does this PR do?

Background Context

Why did you take this approach?

References

Are there any relevant issues / PRs / mailing lists discussions?

@cchantep cchantep force-pushed the task/scalafix branch 5 times, most recently from 727a139 to d9d2563 Compare April 24, 2026 13:07
Remove OfflerGoodCodeSyntax.ignore suppression - now using fixed Offler 1.0.1

Update MacroImpl.scala: Add OfflerGoodCodeSemantic to scalafix:off suppression

This suppression prevents two specific Offler issues:
1. OfflerGoodCodeSyntax would apply formatting changes to complex macro code
2. OfflerGoodCodeSemantic would remove the type annotation from macroCfgInit,
   which is required by the override contract for non-volatile type compatibility.

The scalafix:off comment is placed before the package declaration to ensure
it applies to the entire file and suppresses both Offler rules.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Fix: Apply Offler formatting and structurally prevent type annotation removal

Changes made:
1. Removed scalafix:off workaround from MacroImpl.scala header
2. Applied Offler-recommended formatting fixes:
   - Convert postfix notation to dot notation (c.typecheck -> c typecheck)
   - Move else to same line as closing brace
   - Apply similar formatting throughout the file
3. Fixed macroCfgInit to prevent unwanted type annotation removal:
   - Wrapped body in braces: q{...} -> { q{...} }
   - Makes body non-trivial so Offler's rule doesn't remove required type annotation
   - The type annotation is required for override contract compliance

The actual root cause was that Offler's DefWithTypeTrivalBodyExtractor was treating
the quasiquote body as trivial and removing the type annotation. Wrapping in braces
makes it a block expression (non-trivial), preventing the removal while preserving
semantics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant