Skip to content

Support file paths in CLI positional argument #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
*.code-workspace text eol=lf
*.clang-tidy text eol=lf
*.clang-format text eol=lf
justfile text eol=lf
2 changes: 1 addition & 1 deletion cpp-linter-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ documentation.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.5.16" }
clap = "4.5.16"
git2 = "0.19.0"
lenient_semver = "0.4.2"
log = "0.4.22"
Expand Down
14 changes: 11 additions & 3 deletions cpp-linter-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
# cpp-linter-lib

This crate contains the the library used as a backend for the
`cpp-linter` binary executable.
`cpp-linter` binary executable. The main focus of `cpp-linter` is as follows:

- [x] Lint C/C++ sources using clang-format and clang-tidy.
- [x] Respect file changes when run in a CI workflow on Github.
- [x] Provide feedback via Github's REST API in the any of the following forms:
- [x] step summary
- [x] thread comments
- [x] file annotation
- [ ] pull request review suggestions

Since the [cpp-linter python package][pypi-org] now uses this library
as a binding, the native binary's `main()` method is also present in this
library.
as a binding, the native binary's `main()` behavior is also present in this
library (see `run::run_main()`).

See also the [CLI document hosted on github][gh-pages].

Expand Down
2 changes: 1 addition & 1 deletion cpp-linter-lib/examples/gh_rest_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
let client_controller = GithubApiClient::new();

let file_filter = FileFilter::new(
&["target", ".github"],
&["target".to_string(), ".github".to_string()],
vec!["cpp".to_string(), "hpp".to_string()],
);

Expand Down
17 changes: 1 addition & 16 deletions cpp-linter-lib/src/clang_tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ use which::{which, which_in};
// project-specific modules/crates
use super::common_fs::FileObj;
use crate::{
cli::LinesChangedOnly,
common_fs::FileFilter,
cli::ClangParams,
logger::{end_log_group, start_log_group},
};
pub mod clang_format;
Expand Down Expand Up @@ -77,20 +76,6 @@ pub fn get_clang_tool_exe(name: &str, version: &str) -> Result<PathBuf, &'static
}
}

#[derive(Debug, Clone)]
pub struct ClangParams {
pub tidy_checks: String,
pub lines_changed_only: LinesChangedOnly,
pub database: Option<PathBuf>,
pub extra_args: Option<Vec<String>>,
pub database_json: Option<CompilationDatabase>,
pub style: String,
pub clang_tidy_command: Option<PathBuf>,
pub clang_format_command: Option<PathBuf>,
pub tidy_filter: FileFilter,
pub format_filter: FileFilter,
}

/// This creates a task to run clang-tidy and clang-format on a single file.
///
/// Returns a Future that infallibly resolves to a 2-tuple that contains
Expand Down
Loading