Module dclint

Module dclint 

Source
Expand description

Dclint-RS: Native Rust Docker Compose Linter

A Rust translation of the docker-compose-linter project.

§Attribution

This module is a derivative work based on docker-compose-linter, originally written in TypeScript by Sergey Kupletsky.

Original Project: https://github.com/zavoloklom/docker-compose-linter Original License: MIT

§Features

  • Docker Compose YAML parsing with position tracking
  • 15 configurable linting rules (DCL001-DCL015)
  • Auto-fix capability for 8 rules
  • Multiple output formats (JSON, Stylish, GitHub Actions, etc.)
  • Comment-based rule disabling

§Example

use syncable_cli::analyzer::dclint::{lint, DclintConfig, LintResult};

let compose = r#"
services:
  web:
    image: nginx:latest
    ports:
      - "8080:80"
"#;

let config = DclintConfig::default();
let result = lint(compose, &config);

for failure in result.failures {
    println!("{}: {} - {}", failure.line, failure.code, failure.message);
}

§Rules

CodeNameFixableDescription
DCL001no-build-and-imageNoService cannot have both build and image
DCL002no-duplicate-container-namesNoContainer names must be unique
DCL003no-duplicate-exported-portsNoExported ports must be unique
DCL004no-quotes-in-volumesYesVolume paths should not be quoted
DCL005no-unbound-port-interfacesNoPorts should bind to specific interface
DCL006no-version-fieldYesVersion field is deprecated
DCL007require-project-name-fieldNoRequire top-level name field
DCL008require-quotes-in-portsYesPort mappings should be quoted
DCL009service-container-name-regexNoContainer name format validation
DCL010service-dependencies-alphabetical-orderYesSort depends_on alphabetically
DCL011service-image-require-explicit-tagNoImages need explicit tags
DCL012service-keys-orderYesService keys in standard order
DCL013service-ports-alphabetical-orderYesSort ports alphabetically
DCL014services-alphabetical-orderYesSort services alphabetically
DCL015top-level-properties-orderYesTop-level keys in standard order

Re-exports§

pub use config::DclintConfig;
pub use formatter::OutputFormat;
pub use formatter::format_result;
pub use formatter::format_result_to_string;
pub use formatter::format_results;
pub use lint::LintResult;
pub use lint::fix_content;
pub use lint::fix_file;
pub use lint::lint;
pub use lint::lint_file;
pub use lint::lint_with_path;
pub use types::CheckFailure;
pub use types::ConfigLevel;
pub use types::RuleCategory;
pub use types::RuleCode;
pub use types::RuleMeta;
pub use types::Severity;

Modules§

config
Configuration for the dclint Docker Compose linter.
formatter
Output formatters for dclint results.
lint
Main linting orchestration for dclint.
parser
YAML parser for Docker Compose files.
pragma
Pragma handling for inline rule disabling.
rules
Rule system framework for dclint.
types
Core types for the dclint Docker Compose linter.