Skip to content

Commit dab22ff

Browse files
VLanvinmeta-codesync[bot]
authored andcommitted
Re-add logic to report diagnostics as Severity::Disabled
Summary: Basically a revert of D84170122, clarified in comments. When using `--include-tests`, diagnostics for non-opted-in test suites will be output as `Severity::Disabled`, so as to be registered in contlint but to not appear in CI. Reviewed By: michalmuskala, jcpetruzza Differential Revision: D84914421 fbshipit-source-id: e428de9b0e55c8dda2040f4e030cac32a3201fcd
1 parent 4bde327 commit dab22ff

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

crates/elp/src/bin/reporting.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ impl Reporter for JsonReporter<'_> {
227227
diagnostics: &[EqwalizerDiagnostic],
228228
) -> Result<()> {
229229
let line_index = self.analysis.line_index(file_id)?;
230+
// Pass include_Tests = false so that errors for tests files that are not opted-in are tagged as
231+
// arc_types::Severity::Disabled and don't break CI.
232+
let eqwalizer_enabled = self.analysis.is_eqwalizer_enabled(file_id, false).unwrap();
230233
let file_path = &self.loaded.vfs.file_path(file_id);
231234
let root_path = &self
232235
.analysis
@@ -235,8 +238,12 @@ impl Reporter for JsonReporter<'_> {
235238
.root_dir;
236239
let relative_path = get_relative_path(root_path, file_path);
237240
for diagnostic in diagnostics {
238-
let diagnostic =
239-
convert::eqwalizer_to_arc_diagnostic(diagnostic, &line_index, relative_path);
241+
let diagnostic = convert::eqwalizer_to_arc_diagnostic(
242+
diagnostic,
243+
&line_index,
244+
relative_path,
245+
eqwalizer_enabled,
246+
);
240247
let diagnostic = serde_json::to_string(&diagnostic)?;
241248
writeln!(self.cli, "{diagnostic}")?;
242249
}

crates/elp/src/convert.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,18 @@ pub fn eqwalizer_to_arc_diagnostic(
122122
d: &EqwalizerDiagnostic,
123123
line_index: &LineIndex,
124124
relative_path: &Path,
125+
eqwalizer_enabled: bool,
125126
) -> arc_types::Diagnostic {
126127
let pos = position(line_index, d.range.start());
127128
let line_num = pos.line + 1;
128129
let character = Some(pos.character + 1);
129-
let severity = arc_types::Severity::Error;
130+
let severity = if eqwalizer_enabled {
131+
arc_types::Severity::Error
132+
} else {
133+
// We use Severity::Disabled so that diagnostics are reported in cont lint
134+
// but not in CI.
135+
arc_types::Severity::Disabled
136+
};
130137
// formatting: https://fburl.com/max_wiki_link_to_phabricator_rich_text
131138
let explanation = match &d.explanation {
132139
Some(s) => format!("```\n{s}\n```"),

0 commit comments

Comments
 (0)