fcheck 0.9.10 copy "fcheck: ^0.9.10" to clipboard
fcheck: ^0.9.10 copied to clipboard

A CLI tool for analyzing Flutter and Dart code quality, checking project metrics, comment ratios, class organization, hardcoded strings, and source sorting validation.

fcheck #

Fast quality checks for Flutter and Dart. Run one deterministic command to apply 9 core engineering checks (architecture, risky strings, magic numbers, dead code, duplicates, documentation, and more) without replacing your existing lint setup.

โœจ Why fcheck #

fcheck exists to fill a gap today. The goal is to encourage good engineering practices in the Dart and Flutter ecosystem until these capabilities become first-class in the Flutter SDK.

  • Easy wins: actionable checks in a single run
  • 9-in-1 quality guardrail: vital engineering best-practice checks in one tool
  • Architectural focus: layers, one-class-per-file, sorting
  • Risk detection: secrets, hardcoded strings, magic numbers
  • Code surface reduction: dead code, duplicate code
  • Fast by design: all 9 checks run from a single parse and folder/file traversal, instead of 9 separate tools re-enumerating files and re-parsing code
  • Saves time: no third-party service latency; local runs are typically faster than remote calls
  • Privacy-first: your code is inspected locally, with no network calls required
  • Nice output: JSON and diagrams when you need them
  • Deterministic and imperative: predictable results for repeatable quality workflows
  • Cost and energy conscious: ideal for routine checks you do not need to offload to expensive AI agents

๐Ÿ› ๏ธ Installation #

# Global (recommended)
dart pub global activate fcheck
fcheck .
# Project-local
dart pub add fcheck -d
dart run fcheck .

๐Ÿš€ Quick Start #

If you installed project-local, run the same commands with dart run (for example, dart run fcheck --json).

# Analyze current folder
fcheck .

# Analyze a different folder (positional)
fcheck ../my_app

# Analyze a different folder (explicit option)
fcheck --input ../my_app

# CI-friendly output
fcheck --json

# Generate all dependency graph outputs
fcheck --svg --svgfolder --mermaid --plantuml

๐Ÿงช Local and CI/CD Workflows #

Use the same tool in both places:

  • Local development: run before commit for quick feedback.
  • CI/CD pipelines: run on every PR/push for consistent enforcement.
# Local (global install)
fcheck .

# Local (project-local install)
dart run fcheck .

Example GitHub Actions workflow:

name: fcheck
on:
  pull_request:
  push:
    branches: [main]

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dart-lang/setup-dart@v1
      - run: dart pub global activate fcheck
      - run: dart pub global run fcheck --json > fcheck-report.json
      - uses: actions/upload-artifact@v4
        with:
          name: fcheck-report
          path: fcheck-report.json

For day-to-day engineering guardrails, deterministic static checks are typically faster, cheaper, and lower-energy than repeatedly running AI-agent workflows for the same structural rules.

๐Ÿ“ˆ Example Output #

โ†“----------------------------------- fCheck 0.9.10 -----------------------------------โ†“
Input              : /Users/me/my_app
Dart Project       : my_app (version: 1.0.0)
-------------------------------------- Scorecard --------------------------------------
Compliance Score   : 91%
Suppressions      : -4 pts
Focus Area         : Hardcoded strings (7 issues)
Invest Next        : Adopt localization and replace user-facing literals with keys.
-------------------------------------- Dashboard --------------------------------------
Files              :                   57  |  Dart Files         :                  36
Excluded Files     :                   19  |  Localization (OFF) :       HardCoded   7
Custom Excludes    :                    3  |  Ignore Directives  :                   6
Disabled Rules     :                    1  |  Folders            :                  14
Lines of Code      :                7,550  |  Comments           :         1,452 (19%)
One Class/File     :                    โœ“  |  Magic Numbers      :                   โœ“
Secrets            :                    โœ“  |  Dead Code          :                   โœ“
Layers             :                    6  |  Source Sorting     :                   โœ“
Duplicate Code     :                    โœ“  |  Dependencies       :                  73
---------------------------------------- Lists ----------------------------------------
[โœ“] One class per file check passed.
[-] Hardcoded strings check skipped (localization off).
[โœ“] Magic numbers check passed.
[โœ“] Flutter class member sorting passed.
[โœ“] Secrets scan passed.
[โœ“] Dead code check passed.
[โœ“] Duplicate code check passed.
[โœ“] Layers architecture check passed.
โ†‘----------------------------- fCheck completed (0.43s) ------------------------------โ†‘

๐Ÿ“‹ Usage #

Target Folder #

# Current folder (default)
fcheck .

# Positional folder
fcheck ../my_app

# Explicit folder option (wins over positional folder)
fcheck --input ../my_app

Report Controls #

# Output as JSON (machine-readable)
fcheck --json

# Control list output (console only)
# (ignored when --json is used)
fcheck --list none       # summary only
fcheck --list partial    # top 10 per list (default)
fcheck --list full       # full lists
fcheck --list filenames  # unique file names only

For exclusion commands (--exclude, --excluded), see the Exclusions section below.

Visualizations #

fcheck --svg
fcheck --svgfolder
fcheck --mermaid
fcheck --plantuml

Utility Commands #

# Show help
fcheck --help

# Show version
fcheck --version

# Show ignore setup for each analyzer and .fcheck options
fcheck --help-ignore

# Auto-fix sorting issues
# (applies to Flutter member sorting)
fcheck --fix

๐Ÿ™ˆ Ignore Warnings (Quick Opt-Out) #

You can silence a specific warning with a // ignore: comment on the same line, or ignore an entire file by placing a directive at the top (before any code). Need a quick reminder from CLI? Run fcheck --help-ignore.

File-Level Ignore (entire file) #


// ignore: fcheck_magic_numbers
// ignore: fcheck_secrets
// ignore: fcheck_dead_code
// ignore: fcheck_duplicate_code
// ignore: fcheck_documentation
// ignore: fcheck_layers
// ignore: fcheck_one_class_per_file

Hardcoded Strings (extra ignores) #

fcheck also respects common analyzer ignore comments used in Flutter projects:

// ignore_for_file: avoid_hardcoded_strings_in_widgets

Text('OK'); // ignore: hardcoded.ok
Text('Title'); // ignore: hardcoded.string

๐ŸŽฏ Quality Checks #

Need to silence a rule? See Ignore Warnings above.

Detailed rule behavior and edge cases are documented in the RULES*.md files.

One Class Per File Rule #

  • โœ… Compliant: 1 public class per file (or 2 for StatefulWidget + State)
  • โŒ Violation: Too many public classes in one file
  • ๐Ÿ“š Details: RULES.md

Magic Numbers #

  • ๐Ÿ” Detects: Inline numeric literals that should usually be named constants.
  • ๐Ÿ”ง How to fix: Replace literals with descriptive named values.
  • ๐Ÿ“š Details: RULES_MAGIC_NUMBERS.md

Hardcoded Strings #

  • โš ๏ธ Caution/Error: Potential user-facing strings that should be localized.
  • ๐Ÿ“š Details: RULES_HARDCODED_STRINGS.md

Secrets Detection #

  • ๐Ÿ”’ Security: Detects API keys, tokens, private keys, and other sensitive patterns.
  • ๐Ÿ“š Details: RULES_SECRETS.md

Dead Code #

  • ๐Ÿงน Detects: Unused files, classes, functions, and variables.
  • ๐Ÿ“š Details: RULES_DEAD_CODE.md

Duplicate Code #

  • ๐Ÿงฌ Detects: Similar executable blocks (functions/methods/constructors) with matching parameter signatures.
  • ๐Ÿ“ Threshold: Uses the configured similarity threshold (CLI default: 90%).
  • ๐Ÿ“ฆ Size guard: Default minimums are 20 normalized tokens and 10 non-empty body lines.
  • ๐Ÿ“š Details: RULES_DUPLICATE_CODE.md

Member Sorting #

  • ๐Ÿ”ง Auto-fix: Reorganizes Flutter class members automatically.
  • ๐Ÿ“š Details: RULES_SORTING.md

Layers #

  • ๐Ÿงญ Detects: Layering and cycle issues in dependency graphs.
  • ๐Ÿ“ˆ Outputs: Layer count and dependency count in the report.
  • ๐Ÿ“š Details: RULES_LAYERS.md

๐ŸŒ Visualizations #

SVG Dependency Graph #

fcheck --svg

Generates layers.svg showing:

  • Layered architecture (Layer 1 = entry points)
  • File dependencies with directional edges
  • Interactive tooltips

Dependency Graph Visualization

Folder-Based Visualization #

fcheck --svgfolder
  • Shows files grouped by folders with dependencies.

Folder-Based Dependency Graph Visualization

Mermaid & PlantUML #

fcheck --mermaid    # Generates layers.mmd
fcheck --plantuml   # Generates layers.puml

๐Ÿ›ก๏ธ Exclusions #

Use --exclude to skip custom glob patterns, and --excluded to inspect what was skipped:

# Custom excludes
fcheck --exclude "**/generated/**" --exclude "**/*.g.dart"

# Inspect excluded items
fcheck --excluded
fcheck --excluded --json

Example Output #

Excluded Dart files (18):
  ./test/layers_analyzer_test.dart
  ./test/analyzer_engine_test.dart
  ./example/lib/comments_example.dart
  ./example/lib/subfolder/subclass.dart
  ...

Excluded non-Dart files (1,528):
  ./.DS_Store
  ./.fcheck
  ./example/pubspec.lock
  ./example/layers.svg
  ...

Excluded directories (15):
  ./.git
  ./.dart_tool
  ./test
  ./example
  ./build
  ...

What Gets Excluded #

  • Hidden directories (starting with .), including nested hidden folders
  • Common project directories: test/, example/, tool/, .dart_tool/, build/, .git/, ios/, android/, web/, macos/, windows/, linux/
  • Generated localization files (app_localizations_*.dart, app_localization_*.dart), while keeping app_localizations.dart
  • Files matching .fcheck input.exclude glob patterns
  • Files matching --exclude glob patterns
  • Files in directories that match exclude patterns

๐Ÿ“Š Understanding the Output #

Project Statistics #

  • Folders: Number of directories
  • Files: Total files in project
  • Dart Files: .dart files analyzed
  • Excluded Files: Dart files skipped by defaults and custom patterns
  • Custom Excludes: Dart file count skipped by user exclude globs (.fcheck input.exclude and/or --exclude)
  • Ignore Directives: Count of // ignore: fcheck_* directives
  • Disabled Rules: Number of disabled analyzers
  • Suppression Penalty: Score deduction from overusing excludes/ignores/disabled rules
  • Lines of Code: Total lines in Dart files
  • Comment Ratio: Documentation percentage

Quality Indicators #

  • โœ… All good: No issues found
  • โš ๏ธ Caution: Potential issues (non-blocking)
  • โŒ Error: Violations that need attention
  • ๐Ÿ”ง Fixable: Issues that can be auto-fixed

๐Ÿ”ง Configuration #

Project Configuration (.fcheck) #

Create .fcheck in the directory passed to --input (or the current directory if --input is not set).

input:
  root: app
  exclude:
    - "**/generated/**"
    - "**/*.g.dart"

analyzers:
  default: on
  disabled:
    - hardcoded_strings
    - source_sorting

input.root is resolved relative to the .fcheck file directory.

analyzers.default accepts both on/off and true/false.

To run in opt-in mode (everything off by default):

analyzers:
  default: off
  enabled:
    - magic_numbers
    - secrets

Supported analyzer names:

  • one_class_per_file
  • hardcoded_strings
  • magic_numbers
  • source_sorting
  • layers
  • secrets
  • dead_code
  • duplicate_code
  • documentation

Duplicate code options can be tuned in .fcheck:

analyzers:
  options:
    duplicate_code:
      similarity_threshold: 0.85 # 0.0..1.0
      min_tokens: 20
      min_non_empty_lines: 10

Configuration precedence:

  • Built-in defaults
  • .fcheck
  • CLI flags

For excludes, --exclude adds extra patterns on top of .fcheck input.exclude.

Legacy compatibility is still supported:

ignores:
  magic_numbers: true
  hardcoded_strings: true
  layers: true

Per-line and per-file ignore comments are covered in Ignore Warnings above.

๐Ÿค Contributing #

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Run ./tool/check.sh to ensure quality
  5. Submit a pull request

๐Ÿ“‹ Requirements #

  • Dart SDK >= 3.0.0 < 4.0.0
  • Works with any Flutter/Dart project

๐Ÿ“„ License #

MIT License - see LICENSE file for details.

6
likes
160
points
1.96k
downloads

Publisher

verified publishervteam.com

Weekly Downloads

A CLI tool for analyzing Flutter and Dart code quality, checking project metrics, comment ratios, class organization, hardcoded strings, and source sorting validation.

Repository (GitHub)
View/report issues

Topics

#analysis #architecture #code-style #lint #validation

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, args, glob, path, yaml

More

Packages that depend on fcheck