Function validate

Source
pub fn validate<V: ValidationFormatter>(
    content: &str,
    path: &str,
    formatter: &V,
)
Expand description

Validates the content of an .editorconfig file.

This function parses the provided content of an .editorconfig file, checks for duplicate and similar properties within sections, and validates properties with extended glob patterns. The results of these validations are formatted using the provided formatter.

ยงParameters

  • content - A string slice that holds the content of the .editorconfig file to be validated.
  • path - A string slice that holds the path to the configuration file, used for reporting purposes.
  • formatter - A reference to an implementation of the ValidationFormatter trait, which will be used to format the validation results.

The function performs the following steps:

  1. Parses the content into sections.
  2. Iterates over each section to collect properties and their associated section titles.
  3. Checks for duplicate properties within each section and stores them.
  4. Checks for similar properties within each section and stores them.
  5. Validates properties with extended glob patterns and checks for duplicate and similar properties.
  6. Checks for duplicate section titles.
  7. Constructs a ValidationResult with all the gathered information.
  8. Uses the provided formatter to format the validation results.

The ValidationResult includes:

  • The path of the validated file.
  • A list of duplicate section titles.
  • A map of duplicate properties by section.
  • A map of similar properties by section.
  • A list of problems with properties that have extended glob patterns.