oparlint-linting 0.0.2

Linting infrastructure for oparlint
Documentation
// SPDX-FileCopyrightText: Politik im Blick developers
// SPDX-FileCopyrightText: Wolfgang Silbermayr <wolfgang@silbermayr.at>
//
// SPDX-License-Identifier: AGPL-3.0-or-later OR EUPL-1.2

use crate::{Linter, LintingResult};

/// A trait to be implemented on collections of lints, named a *lint suite*.
///
/// Lint suites can be nested, and they can yield follow-up lints or lint suites
/// that need to be checked under certain circumstances, e.g. depending on the
/// result of a previous check.
#[async_trait::async_trait]
pub trait LintSuite {
    /// The output type of this lint suite. This allows a lint suite to
    /// transform the input data into a different type, e.g. unpacking the
    /// [`Ok`] part from a [`Result`].
    ///
    /// The output of a lint suite can be
    type Output;

    /// The identifier of a lint.
    ///
    /// May only contain lower-case ascii letters, numbers and `-`, and start
    /// with a lower-case ascii letter.
    // TODO: make the identifier its own type.
    fn identifier(&self) -> String;

    /// The title of the suite. Should be just one line of human-readable text.
    fn title(&self) -> String;

    /// Execute the lint suite.
    async fn execute<L: Linter + Send>(self, linter: &mut L) -> LintingResult<Self::Output>;
}