Skip to content

Commit e47d885

Browse files
config: C14 Check unused externs (#1009)
* config: C14 Check unused externs * indexmap, add test * clippy * config: enable c14 by default (#1016) * config: enable c14 by default * change message * Update bin/src/commands/check.rs Co-authored-by: PabstMirror <[email protected]> --------- Co-authored-by: PabstMirror <[email protected]> * Always create .hemttout (for testing) --------- Co-authored-by: BrettMayson <[email protected]>
1 parent a0be3de commit e47d885

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+512
-67
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/src/commands/check.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ pub struct CheckArgs {
2727
#[arg(long, short = 'p', action = clap::ArgAction::SetTrue)]
2828
/// Run all lints that are disabled by default (but not explicitly disabled via project config)
2929
pedantic: bool,
30+
#[arg(long, short = 'L', action = clap::ArgAction::Append)]
31+
/// Explicit Lints
32+
lints: Vec<String>,
3033
}
3134

3235
/// Execute the check command
@@ -46,6 +49,16 @@ pub fn execute(cmd: &Command) -> Result<Report, Error> {
4649
ctx = ctx.with_config(config);
4750
}
4851

52+
if !cmd.check.lints.is_empty() {
53+
let runtime = ctx
54+
.config()
55+
.runtime()
56+
.clone()
57+
.with_explicit_lints(cmd.check.lints.clone());
58+
let config = ctx.config().clone().with_runtime(runtime);
59+
ctx = ctx.with_config(config);
60+
}
61+
4962
let mut executor = Executor::new(ctx);
5063
global_modules(&mut executor);
5164

bin/src/modules/rapifier.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ impl Module for Rapifier {
5151

5252
fn check(&self, ctx: &Context) -> Result<Report, Error> {
5353
let mut report = Report::new();
54-
let default_enabled = ctx.config().runtime().is_pedantic();
5554
report.extend(lint_check(
5655
ctx.config().lints().config().clone(),
57-
default_enabled,
56+
ctx.config().runtime().clone(),
5857
));
5958
Ok(report)
6059
}

bin/src/modules/sqf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ impl Module for SQFCompiler {
4646

4747
fn check(&self, ctx: &Context) -> Result<Report, Error> {
4848
let mut report = Report::new();
49-
let default_enabled = ctx.config().runtime().is_pedantic();
5049
report.extend(lint_check(
5150
ctx.config().lints().sqf().clone(),
52-
default_enabled,
51+
ctx.config().runtime().clone(),
5352
));
5453
Ok(report)
5554
}

bin/src/modules/stringtables.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ impl Module for Stringtables {
3737

3838
fn check(&self, ctx: &crate::context::Context) -> Result<crate::report::Report, crate::Error> {
3939
let mut report = Report::new();
40-
let default_enabled = ctx.config().runtime().is_pedantic();
4140
report.extend(lint_check(
4241
ctx.config().lints().stringtables().clone(),
43-
default_enabled,
42+
ctx.config().runtime().clone(),
4443
));
4544
Ok(report)
4645
}

libs/common/src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub use addon::AddonConfig;
1212
pub use pdrive::PDriveOption;
1313
pub use project::{
1414
ProjectConfig,
15-
hemtt::launch::LaunchOptions,
15+
hemtt::{RuntimeArguments, launch::LaunchOptions},
1616
lint::{LintConfig, LintConfigOverride, LintEnabled},
1717
};
1818

libs/common/src/config/project/hemtt/mod.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub mod dev;
44
pub mod launch;
55
pub mod release;
66

7-
use std::{collections::HashMap, path::Path};
7+
use std::{collections::HashMap, path::Path, sync::Arc};
88

99
use launch::LaunchOptions;
1010
use serde::{Deserialize, Serialize};
@@ -58,6 +58,8 @@ pub struct RuntimeArguments {
5858
is_release: bool,
5959
is_pedantic: bool,
6060
is_just: bool,
61+
62+
explicit_lints: Arc<[String]>,
6163
}
6264

6365
impl RuntimeArguments {
@@ -67,7 +69,7 @@ impl RuntimeArguments {
6769
}
6870

6971
#[must_use]
70-
pub const fn with_release(self, is_release: bool) -> Self {
72+
pub fn with_release(self, is_release: bool) -> Self {
7173
Self { is_release, ..self }
7274
}
7375

@@ -77,7 +79,7 @@ impl RuntimeArguments {
7779
}
7880

7981
#[must_use]
80-
pub const fn with_pedantic(self, is_pedantic: bool) -> Self {
82+
pub fn with_pedantic(self, is_pedantic: bool) -> Self {
8183
Self {
8284
is_pedantic,
8385
..self
@@ -90,9 +92,22 @@ impl RuntimeArguments {
9092
}
9193

9294
#[must_use]
93-
pub const fn with_just(self, is_just: bool) -> Self {
95+
pub fn with_just(self, is_just: bool) -> Self {
9496
Self { is_just, ..self }
9597
}
98+
99+
#[must_use]
100+
pub fn explicit_lints(&self) -> &[String] {
101+
&self.explicit_lints
102+
}
103+
104+
#[must_use]
105+
pub fn with_explicit_lints(self, explicit_lints: Vec<String>) -> Self {
106+
Self {
107+
explicit_lints: explicit_lints.into(),
108+
..self
109+
}
110+
}
96111
}
97112

98113
#[allow(clippy::module_name_repetitions)]

libs/config/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ hemtt-workspace = { path = "../workspace" }
1919
automod = { workspace = true }
2020
byteorder = { workspace = true }
2121
chumsky = { workspace = true }
22+
indexmap = { workspace = true }
2223
linkme = { workspace = true }
2324
lsp-types = { workspace = true }
2425
toml = { workspace = true }

libs/config/src/analyze/lints/c01_invalid_value.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl LintRunner<LintData> for RunnerValue {
6363
_project: Option<&ProjectConfig>,
6464
_config: &LintConfig,
6565
processed: Option<&Processed>,
66+
_runtime: &hemtt_common::config::RuntimeArguments,
6667
target: &Value,
6768
_data: &LintData,
6869
) -> Codes {
@@ -92,6 +93,7 @@ impl LintRunner<LintData> for RunnerItem {
9293
_project: Option<&ProjectConfig>,
9394
_config: &LintConfig,
9495
processed: Option<&Processed>,
96+
_runtime: &hemtt_common::config::RuntimeArguments,
9597
target: &Item,
9698
_data: &LintData,
9799
) -> Codes {

libs/config/src/analyze/lints/c02_duplicate_property.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ impl LintRunner<LintData> for Runner {
6767
_project: Option<&ProjectConfig>,
6868
_config: &LintConfig,
6969
processed: Option<&Processed>,
70+
_runtime: &hemtt_common::config::RuntimeArguments,
7071
target: &Config,
7172
_data: &LintData,
7273
) -> Codes {

0 commit comments

Comments
 (0)