visibility-pattern-guardian

Detect private methods and inline lambdas in Scala code that reduce testability.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/matthew-bram/enterprise-confluent-test-probe --skill visibility-pattern-guardian
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: visibility-pattern-guardian
Source: https://github.com/matthew-bram/enterprise-confluent-test-probe/tree/main/.claude/skills/visibility-pattern-guardian
Command: npx skills add https://github.com/matthew-bram/enterprise-confluent-test-probe --skill visibility-pattern-guardian

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents significant code coverage loss (20-40%) caused by the misuse of private methods, ensuring code remains testable and maintainable by adhering to established visibility patterns.

Core Features & Use Cases

  • Detects Violations: Identifies private methods and inline lambdas that hinder unit testing.
  • References Style Guides: Points developers to authoritative documentation for pattern guidance, avoiding duplication.
  • Enforces Patterns: Blocks code reviews for non-compliance and offers auto-refactoring.
  • Use Case: Automatically refactor an actor object with multiple private methods into a private[module] scoped object with public methods, making all internal logic unit-testable and increasing coverage from 45% to over 85%.

Quick Start

Use the visibility-pattern-guardian skill to refactor private methods in GuardianActor.scala to private[core] object with public methods.

Frequently Asked Questions about visibility-pattern-guardian

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does private method usage cause code coverage loss in Scala?

Private methods in Scala restrict unit test access to internal logic, causing 20-40% code coverage loss. Moving business logic to public methods within module-scoped objects restores testability and improves coverage metrics.

How do I refactor Scala private methods to increase unit test coverage?

To refactor Scala private methods for unit test coverage, extract inline lambdas into named functions and change private methods to public methods within private[module] scoped objects. This auto-refactoring approach can increase coverage from 45% to over 85%.

What is the best way to enforce testability patterns during Scala code reviews?

The best way to enforce testability patterns during Scala code reviews is to block non-compliant code by detecting private methods and inline lambdas. Referencing authoritative style guides ensures developers follow established visibility patterns before merging.

Can I automatically detect and fix inline lambdas that reduce Scala code coverage?

Yes, you can automatically detect and fix inline lambdas that reduce Scala code coverage. The refactoring process extracts inline lambdas into named functions, requiring user approval before applying changes to ensure testability.

Does refactoring private methods into module-scoped objects work for complex Scala actors?

Refactoring private methods into module-scoped objects works effectively for complex Scala actors. By converting an actor object with multiple private methods into a private[module] scoped object with public methods, all internal logic becomes unit-testable.