Skip to content

Commit

Permalink
[x-lint] add a stub for project linters
Browse files Browse the repository at this point in the history
Closes: diem#3364
Approved by: bmwill
  • Loading branch information
sunshowers authored and bors-libra committed Apr 10, 2020
1 parent 797a4f4 commit 8ebf9de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion devtools/x-lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub mod prelude {
pub use super::{
content::{ContentContext, ContentLinter},
file::FileContext,
project::ProjectContext,
project::{ProjectContext, ProjectLinter},
LintFormatter, LintKind, LintLevel, LintMessage, LintSource, Linter, Result, RunStatus,
SkipReason, SystemError,
};
Expand Down
15 changes: 14 additions & 1 deletion devtools/x-lint/src/project.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::{LintContext, LintKind};
use crate::prelude::*;
use crate::LintContext;
use std::path::{Path, PathBuf};

/// Represents a linter that checks some property for the overall project.
///
/// Linters that implement `ProjectLinter` will run once for the whole project.
pub trait ProjectLinter: Linter {
/// Executes the lint against the given project context.
fn run<'l>(
&self,
ctx: &ProjectContext<'l>,
out: &mut LintFormatter<'l, '_>,
) -> Result<RunStatus<'l>>;
}

/// Overall linter context for a project.
#[derive(Copy, Clone, Debug)]
pub struct ProjectContext<'l> {
Expand Down

0 comments on commit 8ebf9de

Please sign in to comment.