mirror of
https://github.com/WhatsApp/erlang-language-platform.git
synced 2025-12-23 12:26:48 +00:00
Remove logic for --include-tests, opt-in tests
Some checks are pending
ELP CI / edb (push) Waiting to run
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, true, linux-x64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, true, linux-arm64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-15-intel, macos-15-x64, x86_64-apple-darwin, true, darwin-x64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-latest, macos-latest-arm, aarch64-apple-darwin, true, darwin-arm64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, windows, 26.2, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, true, win32-x64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-15-intel, macos-15-x64, x86_64-apple-darwin, false, darwin-x64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, windows, 27.3, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, macos, 28, macos-15-intel, macos-15-x64, x86_64-apple-darwin, false, darwin-x64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, macos, 28, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, windows, 28, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Blocked by required conditions
Deploy Website to GitHub Pages / Deploy Website to GitHub Pages (push) Waiting to run
Some checks are pending
ELP CI / edb (push) Waiting to run
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, true, linux-x64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, true, linux-arm64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-15-intel, macos-15-x64, x86_64-apple-darwin, true, darwin-x64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-latest, macos-latest-arm, aarch64-apple-darwin, true, darwin-arm64) (push) Blocked by required conditions
ELP CI / ci (26, 26.2.5.13, windows, 26.2, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, true, win32-x64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-15-intel, macos-15-x64, x86_64-apple-darwin, false, darwin-x64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Blocked by required conditions
ELP CI / ci (27, 27.3.4, windows, 27.3, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, macos, 28, macos-15-intel, macos-15-x64, x86_64-apple-darwin, false, darwin-x64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, macos, 28, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Blocked by required conditions
ELP CI / ci (28, 28.0.1, windows, 28, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Blocked by required conditions
Deploy Website to GitHub Pages / Deploy Website to GitHub Pages (push) Waiting to run
Summary: Remove all logic related to `--include-tests` in ELP for eqWAlizer. Enable eqWAlizer on tests by default. Reviewed By: michalmuskala Differential Revision: D89049936 fbshipit-source-id: b3702ddcc8cdb9a3ced65ec6855918ea37b2a072
This commit is contained in:
parent
b525eac0ea
commit
166770cc92
21 changed files with 65 additions and 75 deletions
|
|
@ -155,8 +155,6 @@ pub struct EqwalizeAll {
|
|||
/// Also eqwalize opted-in generated modules from project (deprecated)
|
||||
#[bpaf(hide)]
|
||||
pub include_generated: bool,
|
||||
/// Also eqwalize test modules from project
|
||||
pub include_tests: bool,
|
||||
/// Exit with a non-zero status code if any errors are found
|
||||
pub bail_on_error: bool,
|
||||
/// Print statistics when done
|
||||
|
|
@ -173,8 +171,6 @@ pub struct EqwalizeTarget {
|
|||
/// Also eqwalize opted-in generated modules from application (deprecated)
|
||||
#[bpaf(hide)]
|
||||
pub include_generated: bool,
|
||||
/// Also eqwalize test modules from project
|
||||
pub include_tests: bool,
|
||||
/// Exit with a non-zero status code if any errors are found
|
||||
pub bail_on_error: bool,
|
||||
/// target, like //erl/chatd/...
|
||||
|
|
@ -193,8 +189,6 @@ pub struct EqwalizeApp {
|
|||
/// Also eqwalize opted-in generated modules from project (deprecated)
|
||||
#[bpaf(hide)]
|
||||
pub include_generated: bool,
|
||||
/// Also eqwalize test modules from project
|
||||
pub include_tests: bool,
|
||||
/// Run with rebar
|
||||
pub rebar: bool,
|
||||
/// Exit with a non-zero status code if any errors are found
|
||||
|
|
@ -217,8 +211,6 @@ pub struct EqwalizeStats {
|
|||
/// Also eqwalize opted-in generated modules from project (deprecated)
|
||||
#[bpaf(hide)]
|
||||
pub include_generated: bool,
|
||||
/// Also eqwalize test modules from project
|
||||
pub include_tests: bool,
|
||||
/// If specified, use the provided CLI severity mapping instead of the default one
|
||||
pub use_cli_severity: bool,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,10 +186,7 @@ pub fn do_eqwalize_all(
|
|||
.par_bridge()
|
||||
.progress_with(pb.clone())
|
||||
.map_with(analysis.clone(), |analysis, (name, _source, file_id)| {
|
||||
if analysis
|
||||
.should_eqwalize(file_id, args.include_tests)
|
||||
.unwrap()
|
||||
&& !otp_file_to_ignore(analysis, file_id)
|
||||
if analysis.should_eqwalize(file_id).unwrap() && !otp_file_to_ignore(analysis, file_id)
|
||||
{
|
||||
if args.stats {
|
||||
add_stat(name.to_string());
|
||||
|
|
@ -269,9 +266,7 @@ pub fn do_eqwalize_app(
|
|||
.iter_own()
|
||||
.filter_map(|(_name, _source, file_id)| {
|
||||
if analysis.file_app_name(file_id).ok()? == Some(AppName(args.app.clone()))
|
||||
&& analysis
|
||||
.should_eqwalize(file_id, args.include_tests)
|
||||
.unwrap()
|
||||
&& analysis.should_eqwalize(file_id).unwrap()
|
||||
&& !otp_file_to_ignore(analysis, file_id)
|
||||
{
|
||||
Some(file_id)
|
||||
|
|
@ -339,9 +334,7 @@ pub fn eqwalize_target(
|
|||
let vfs_path = VfsPath::from(src.clone());
|
||||
if let Some((file_id, _)) = loaded.vfs.file_id(&vfs_path) {
|
||||
at_least_one_found = true;
|
||||
if analysis
|
||||
.should_eqwalize(file_id, args.include_tests)
|
||||
.unwrap()
|
||||
if analysis.should_eqwalize(file_id).unwrap()
|
||||
&& !otp_file_to_ignore(analysis, file_id)
|
||||
{
|
||||
file_ids.push(file_id);
|
||||
|
|
@ -408,9 +401,7 @@ pub fn eqwalize_stats(
|
|||
.par_bridge()
|
||||
.progress_with(pb.clone())
|
||||
.map_with(analysis.clone(), |analysis, (name, _source, file_id)| {
|
||||
if analysis
|
||||
.should_eqwalize(file_id, args.include_tests)
|
||||
.expect("cancelled")
|
||||
if analysis.should_eqwalize(file_id).expect("cancelled")
|
||||
&& !otp_file_to_ignore(analysis, file_id)
|
||||
{
|
||||
analysis
|
||||
|
|
|
|||
|
|
@ -1560,7 +1560,7 @@ impl GleanIndexer {
|
|||
vars: FxHashMap<&Location, &String>,
|
||||
) -> Vec<VarDecl> {
|
||||
let mut result = vec![];
|
||||
if !db.is_eqwalizer_enabled(file_id, false) {
|
||||
if !db.is_eqwalizer_enabled(file_id) {
|
||||
return result;
|
||||
}
|
||||
let module_diagnostics = db.eqwalizer_diagnostics_by_project(project_id, vec![file_id]);
|
||||
|
|
|
|||
|
|
@ -227,9 +227,6 @@ impl Reporter for JsonReporter<'_> {
|
|||
diagnostics: &[EqwalizerDiagnostic],
|
||||
) -> Result<()> {
|
||||
let line_index = self.analysis.line_index(file_id)?;
|
||||
// Pass include_Tests = false so that errors for tests files that are not opted-in are tagged as
|
||||
// arc_types::Severity::Disabled and don't break CI.
|
||||
let eqwalizer_enabled = self.analysis.is_eqwalizer_enabled(file_id, false).unwrap();
|
||||
let file_path = &self.loaded.vfs.file_path(file_id);
|
||||
let root_path = &self
|
||||
.analysis
|
||||
|
|
@ -238,12 +235,8 @@ impl Reporter for JsonReporter<'_> {
|
|||
.root_dir;
|
||||
let relative_path = get_relative_path(root_path, file_path);
|
||||
for diagnostic in diagnostics {
|
||||
let diagnostic = convert::eqwalizer_to_arc_diagnostic(
|
||||
diagnostic,
|
||||
&line_index,
|
||||
relative_path,
|
||||
eqwalizer_enabled,
|
||||
);
|
||||
let diagnostic =
|
||||
convert::eqwalizer_to_arc_diagnostic(diagnostic, &line_index, relative_path);
|
||||
let diagnostic = serde_json::to_string(&diagnostic)?;
|
||||
writeln!(self.cli, "{diagnostic}")?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,10 +157,9 @@ impl ShellCommand {
|
|||
}
|
||||
"eqwalize-app" => {
|
||||
let include_generated = options.contains(&"--include-generated");
|
||||
let include_tests = options.contains(&"--include-tests");
|
||||
if let Some(other) = options
|
||||
.into_iter()
|
||||
.find(|&opt| opt != "--include-generated" && opt != "--include-tests")
|
||||
.find(|&opt| opt != "--include-generated")
|
||||
{
|
||||
return Err(ShellError::UnexpectedOption(
|
||||
"eqwalize-app".into(),
|
||||
|
|
@ -177,7 +176,6 @@ impl ShellCommand {
|
|||
rebar,
|
||||
app: app.into(),
|
||||
include_generated,
|
||||
include_tests,
|
||||
bail_on_error: false,
|
||||
})));
|
||||
}
|
||||
|
|
@ -185,10 +183,9 @@ impl ShellCommand {
|
|||
}
|
||||
"eqwalize-all" => {
|
||||
let include_generated = options.contains(&"--include-generated");
|
||||
let include_tests = options.contains(&"--include-tests");
|
||||
if let Some(other) = options
|
||||
.into_iter()
|
||||
.find(|&opt| opt != "--include-generated" && opt != "--include-tests")
|
||||
.find(|&opt| opt != "--include-generated")
|
||||
{
|
||||
return Err(ShellError::UnexpectedOption(
|
||||
"eqwalize-all".into(),
|
||||
|
|
@ -204,7 +201,6 @@ impl ShellCommand {
|
|||
rebar,
|
||||
format: None,
|
||||
include_generated,
|
||||
include_tests,
|
||||
bail_on_error: false,
|
||||
stats: false,
|
||||
list_modules: false,
|
||||
|
|
@ -226,10 +222,8 @@ COMMANDS:
|
|||
eqwalize <modules> Eqwalize specified modules
|
||||
--clause-coverage Use experimental clause coverage checker
|
||||
eqwalize-all Eqwalize all modules in the current project
|
||||
--include-tests Also eqwalize test modules from project
|
||||
--clause-coverage Use experimental clause coverage checker
|
||||
eqwalize-app <app> Eqwalize all modules in specified application
|
||||
--include-tests Also eqwalize test modules from project
|
||||
--clause-coverage Use experimental clause coverage checker
|
||||
";
|
||||
|
||||
|
|
|
|||
|
|
@ -126,18 +126,11 @@ pub fn eqwalizer_to_arc_diagnostic(
|
|||
d: &EqwalizerDiagnostic,
|
||||
line_index: &LineIndex,
|
||||
relative_path: &Path,
|
||||
eqwalizer_enabled: bool,
|
||||
) -> arc_types::Diagnostic {
|
||||
let pos = position(line_index, d.range.start());
|
||||
let line_num = pos.line + 1;
|
||||
let character = Some(pos.character + 1);
|
||||
let severity = if eqwalizer_enabled {
|
||||
arc_types::Severity::Error
|
||||
} else {
|
||||
// We use Severity::Disabled so that diagnostics are reported in cont lint
|
||||
// but not in CI.
|
||||
arc_types::Severity::Disabled
|
||||
};
|
||||
let severity = arc_types::Severity::Error;
|
||||
// formatting: https://fburl.com/max_wiki_link_to_phabricator_rich_text
|
||||
let explanation = match &d.explanation {
|
||||
Some(s) => format!("```\n{s}\n```"),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
Usage: [--project PROJECT] [--as PROFILE] [[--format FORMAT]] [--rebar] [--include-tests] [--bail-on-error] [--stats] [--list-modules]
|
||||
Usage: [--project PROJECT] [--as PROFILE] [[--format FORMAT]] [--rebar] [--bail-on-error] [--stats] [--list-modules]
|
||||
|
||||
Available options:
|
||||
--project <PROJECT> Path to directory with project, or to a JSON file (defaults to `.`)
|
||||
--as <PROFILE> Rebar3 profile to pickup (default is test)
|
||||
--format <FORMAT> Show diagnostics in JSON format
|
||||
--rebar Run with rebar
|
||||
--include-tests Also eqwalize test modules from project
|
||||
--bail-on-error Exit with a non-zero status code if any errors are found
|
||||
--stats Print statistics when done
|
||||
--list-modules When printing statistics, include the list of modules parsed
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Usage: [--project PROJECT] [--as PROFILE] [--include-tests] [--rebar] [--bail-on-error] <APP>
|
||||
Usage: [--project PROJECT] [--as PROFILE] [--rebar] [--bail-on-error] <APP>
|
||||
|
||||
Available positional items:
|
||||
<APP> app name
|
||||
|
|
@ -6,7 +6,6 @@ Available positional items:
|
|||
Available options:
|
||||
--project <PROJECT> Path to directory with project, or to a JSON file (defaults to `.`)
|
||||
--as <PROFILE> Rebar3 profile to pickup (default is test)
|
||||
--include-tests Also eqwalize test modules from project
|
||||
--rebar Run with rebar
|
||||
--bail-on-error Exit with a non-zero status code if any errors are found
|
||||
-h, --help Prints help information
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
Usage: [--project PROJECT] [--include-tests] [--bail-on-error] <TARGET>
|
||||
Usage: [--project PROJECT] [--bail-on-error] <TARGET>
|
||||
|
||||
Available positional items:
|
||||
<TARGET> target, like //erl/chatd/...
|
||||
|
||||
Available options:
|
||||
--project <PROJECT> Path to directory with project, or to a JSON file (defaults to `.`)
|
||||
--include-tests Also eqwalize test modules from project
|
||||
--bail-on-error Exit with a non-zero status code if any errors are found
|
||||
-h, --help Prints help information
|
||||
|
|
|
|||
|
|
@ -192,6 +192,14 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
|
|||
Expression has type: 'wrong_ret'
|
||||
Context expected type: 'error'
|
||||
|
||||
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
|
||||
┌─ app_a/test/app_a_test_helpers_not_opted_in.erl:5:11
|
||||
│
|
||||
5 │ fail() -> error.
|
||||
│ ^^^^^ 'error'.
|
||||
Expression has type: 'error'
|
||||
Context expected type: 'ok'
|
||||
|
||||
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
|
||||
┌─ app_b/src/app_b.erl:16:5
|
||||
│
|
||||
|
|
@ -200,4 +208,4 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
|
|||
Expression has type: [T]
|
||||
Context expected type: T
|
||||
|
||||
20 ERRORS
|
||||
21 ERRORS
|
||||
|
|
|
|||
|
|
@ -17,4 +17,5 @@
|
|||
{"path":"app_a/src/app_a_mod2.erl","line":22,"char":1,"code":"ELP","severity":"error","name":"eqWAlizer: type_alias_is_non_productive","original":null,"replacement":null,"description":"```lang=error,counterexample\n\nrecursive type invalid/0 is not productive\n```\n\n> [docs on `type_alias_is_non_productive`](https://fb.me/eqwalizer_errors#type_alias_is_non_productive)","docPath":null}
|
||||
{"path":"app_a/src/app_a_mod2.erl","line":31,"char":9,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"'an_atom'","replacement":null,"description":"```lang=error,counterexample\n`'an_atom'`.\n\nExpression has type: 'an_atom'\nContext expected type: number()\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
{"path":"app_a/test/app_a_test_helpers.erl","line":6,"char":11,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"'wrong_ret'","replacement":null,"description":"```lang=error,counterexample\n`'wrong_ret'`.\n\nExpression has type: 'wrong_ret'\nContext expected type: 'error'\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
{"path":"app_a/test/app_a_test_helpers_not_opted_in.erl","line":5,"char":11,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"'error'","replacement":null,"description":"```lang=error,counterexample\n`'error'`.\n\nExpression has type: 'error'\nContext expected type: 'ok'\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
{"path":"app_b/src/app_b.erl","line":16,"char":5,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"L","replacement":null,"description":"```lang=error,counterexample\n`L`.\n\nExpression has type: [T]\nContext expected type: T\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
|
|
|
|||
|
|
@ -192,6 +192,14 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
|
|||
Expression has type: 'wrong_ret'
|
||||
Context expected type: 'error'
|
||||
|
||||
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
|
||||
┌─ app_a/test/app_a_test_helpers_not_opted_in.erl:5:11
|
||||
│
|
||||
5 │ fail() -> error.
|
||||
│ ^^^^^ 'error'.
|
||||
Expression has type: 'error'
|
||||
Context expected type: 'ok'
|
||||
|
||||
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
|
||||
┌─ app_b/src/app_b.erl:16:5
|
||||
│
|
||||
|
|
@ -200,4 +208,4 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
|
|||
Expression has type: [T]
|
||||
Context expected type: T
|
||||
|
||||
20 ERRORS
|
||||
21 ERRORS
|
||||
|
|
|
|||
|
|
@ -17,4 +17,5 @@
|
|||
{"path":"app_a/src/app_a_mod2.erl","line":22,"char":1,"code":"ELP","severity":"error","name":"eqWAlizer: type_alias_is_non_productive","original":null,"replacement":null,"description":"```lang=error,counterexample\n\nrecursive type invalid/0 is not productive\n```\n\n> [docs on `type_alias_is_non_productive`](https://fb.me/eqwalizer_errors#type_alias_is_non_productive)","docPath":null}
|
||||
{"path":"app_a/src/app_a_mod2.erl","line":31,"char":9,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"'an_atom'","replacement":null,"description":"```lang=error,counterexample\n`'an_atom'`.\n\nExpression has type: 'an_atom'\nContext expected type: number()\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
{"path":"app_a/test/app_a_test_helpers.erl","line":6,"char":11,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"'wrong_ret'","replacement":null,"description":"```lang=error,counterexample\n`'wrong_ret'`.\n\nExpression has type: 'wrong_ret'\nContext expected type: 'error'\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
{"path":"app_a/test/app_a_test_helpers_not_opted_in.erl","line":5,"char":11,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"'error'","replacement":null,"description":"```lang=error,counterexample\n`'error'`.\n\nExpression has type: 'error'\nContext expected type: 'ok'\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
{"path":"app_b/src/app_b.erl","line":16,"char":5,"code":"ELP","severity":"error","name":"eqWAlizer: incompatible_types","original":"L","replacement":null,"description":"```lang=error,counterexample\n`L`.\n\nExpression has type: [T]\nContext expected type: T\n```\n\n> [docs on `incompatible_types`](https://fb.me/eqwalizer_errors#incompatible_types)","docPath":null}
|
||||
|
|
|
|||
|
|
@ -192,4 +192,12 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
|
|||
Expression has type: 'wrong_ret'
|
||||
Context expected type: 'error'
|
||||
|
||||
19 ERRORS
|
||||
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
|
||||
┌─ app_a/test/app_a_test_helpers_not_opted_in.erl:5:11
|
||||
│
|
||||
5 │ fail() -> error.
|
||||
│ ^^^^^ 'error'.
|
||||
Expression has type: 'error'
|
||||
Context expected type: 'ok'
|
||||
|
||||
20 ERRORS
|
||||
|
|
|
|||
|
|
@ -192,4 +192,12 @@ error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types
|
|||
Expression has type: 'wrong_ret'
|
||||
Context expected type: 'error'
|
||||
|
||||
19 ERRORS
|
||||
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
|
||||
┌─ app_a/test/app_a_test_helpers_not_opted_in.erl:5:11
|
||||
│
|
||||
5 │ fail() -> error.
|
||||
│ ^^^^^ 'error'.
|
||||
Expression has type: 'error'
|
||||
Context expected type: 'ok'
|
||||
|
||||
20 ERRORS
|
||||
|
|
|
|||
|
|
@ -2073,7 +2073,7 @@ impl Server {
|
|||
};
|
||||
|
||||
for (_, _, file_id) in module_index.iter_own() {
|
||||
match snapshot.analysis.should_eqwalize(file_id, false) {
|
||||
match snapshot.analysis.should_eqwalize(file_id) {
|
||||
Ok(true) => {
|
||||
files.push(file_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ impl Snapshot {
|
|||
) -> Result<()> {
|
||||
let _ = self.analysis.def_map(file_id)?;
|
||||
if optimize_for_eqwalizer {
|
||||
let should_eqwalize = self.analysis.should_eqwalize(file_id, false)?;
|
||||
let should_eqwalize = self.analysis.should_eqwalize(file_id)?;
|
||||
if should_eqwalize {
|
||||
let _ = self.analysis.module_ast(file_id)?;
|
||||
}
|
||||
|
|
@ -242,7 +242,7 @@ impl Snapshot {
|
|||
let file_ids: Vec<FileId> = module_index
|
||||
.iter_own()
|
||||
.filter_map(|(_, _, file_id)| {
|
||||
if let Ok(true) = self.analysis.should_eqwalize(file_id, false) {
|
||||
if let Ok(true) = self.analysis.should_eqwalize(file_id) {
|
||||
Some(file_id)
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ mod tests {
|
|||
let ast = analysis.module_ast(file_id).unwrap();
|
||||
assert_eq!(ast.errors, vec![]);
|
||||
let eq_enabled = analysis
|
||||
.is_eqwalizer_enabled(file_id, false)
|
||||
.is_eqwalizer_enabled(file_id)
|
||||
.unwrap_or_else(|_| panic!("Failed to check if eqwalizer enabled for {module}"));
|
||||
assert_eq!(eq_enabled, eqwalizer_enabled);
|
||||
let project_data = analysis.project_data(file_id).unwrap();
|
||||
|
|
|
|||
|
|
@ -251,9 +251,9 @@ impl Analysis {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn should_eqwalize(&self, file_id: FileId, include_tests: bool) -> Cancellable<bool> {
|
||||
pub fn should_eqwalize(&self, file_id: FileId) -> Cancellable<bool> {
|
||||
let is_in_app = self.file_app_type(file_id).ok() == Some(Some(AppType::App));
|
||||
Ok(is_in_app && self.is_eqwalizer_enabled(file_id, include_tests)?)
|
||||
Ok(is_in_app && self.is_eqwalizer_enabled(file_id)?)
|
||||
}
|
||||
|
||||
/// Computes the set of eqwalizer diagnostics for the given files,
|
||||
|
|
@ -383,8 +383,8 @@ impl Analysis {
|
|||
/// - the app (the module belongs to) has `.eqwalizer` marker in the roof
|
||||
/// - or the module has `-typing([eqwalizer]).` pragma
|
||||
/// - or the whole project has `enable_all=true` in its `.elp.toml` file
|
||||
pub fn is_eqwalizer_enabled(&self, file_id: FileId, include_tests: bool) -> Cancellable<bool> {
|
||||
self.with_db(|db| db.is_eqwalizer_enabled(file_id, include_tests))
|
||||
pub fn is_eqwalizer_enabled(&self, file_id: FileId) -> Cancellable<bool> {
|
||||
self.with_db(|db| db.is_eqwalizer_enabled(file_id))
|
||||
}
|
||||
|
||||
/// ETF for the module's abstract forms
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use std::sync::Arc;
|
|||
|
||||
use elp_base_db::FileId;
|
||||
use elp_base_db::FileRange;
|
||||
use elp_base_db::FileSource;
|
||||
use elp_base_db::ModuleName;
|
||||
use elp_base_db::ProjectId;
|
||||
use elp_base_db::SourceDatabase;
|
||||
|
|
@ -89,7 +88,7 @@ pub trait EqwalizerDatabase:
|
|||
fn types_for_file(&self, file_id: FileId) -> Option<Arc<Vec<(Pos, Type)>>>;
|
||||
fn has_eqwalizer_module_marker(&self, file_id: FileId) -> bool;
|
||||
fn has_eqwalizer_ignore_marker(&self, file_id: FileId) -> bool;
|
||||
fn is_eqwalizer_enabled(&self, file_id: FileId, include_tests: bool) -> bool;
|
||||
fn is_eqwalizer_enabled(&self, file_id: FileId) -> bool;
|
||||
}
|
||||
|
||||
pub fn eqwalizer_diagnostics_by_project(
|
||||
|
|
@ -114,7 +113,7 @@ fn type_at_position(
|
|||
db: &dyn EqwalizerDatabase,
|
||||
range: FileRange,
|
||||
) -> Option<Arc<(eqwalizer::types::Type, FileRange)>> {
|
||||
if !db.is_eqwalizer_enabled(range.file_id, false) {
|
||||
if !db.is_eqwalizer_enabled(range.file_id) {
|
||||
return None;
|
||||
}
|
||||
let project_id = db.file_app_data(range.file_id)?.project_id;
|
||||
|
|
@ -149,7 +148,7 @@ fn type_at_position(
|
|||
}
|
||||
|
||||
fn types_for_file(db: &dyn EqwalizerDatabase, file_id: FileId) -> Option<Arc<Vec<(Pos, Type)>>> {
|
||||
if !db.is_eqwalizer_enabled(file_id, false) {
|
||||
if !db.is_eqwalizer_enabled(file_id) {
|
||||
return None;
|
||||
}
|
||||
let project_id = db.file_app_data(file_id)?.project_id;
|
||||
|
|
@ -162,7 +161,7 @@ fn types_for_file(db: &dyn EqwalizerDatabase, file_id: FileId) -> Option<Arc<Vec
|
|||
None
|
||||
}
|
||||
|
||||
fn is_eqwalizer_enabled(db: &dyn EqwalizerDatabase, file_id: FileId, include_tests: bool) -> bool {
|
||||
fn is_eqwalizer_enabled(db: &dyn EqwalizerDatabase, file_id: FileId) -> bool {
|
||||
if !otp_supported_by_eqwalizer() {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -178,11 +177,8 @@ fn is_eqwalizer_enabled(db: &dyn EqwalizerDatabase, file_id: FileId, include_tes
|
|||
let project = db.project_data(project_id);
|
||||
let eqwalizer_config = &project.eqwalizer_config;
|
||||
let module_index = db.module_index(project_id);
|
||||
let is_src = module_index.file_source_for_file(file_id) == Some(FileSource::Src);
|
||||
let is_test_opted_in = db.is_test_suite_or_test_helper(file_id) == Some(true) && include_tests;
|
||||
let global_opt_in = eqwalizer_config.enable_all;
|
||||
let opt_in =
|
||||
(global_opt_in && (is_src || is_test_opted_in)) || db.has_eqwalizer_module_marker(file_id);
|
||||
let opt_in = global_opt_in || db.has_eqwalizer_module_marker(file_id);
|
||||
let ignored_in_config = if let Some(module_name) = module_index.module_for_file(file_id) {
|
||||
eqwalizer_config
|
||||
.ignore_modules_compiled_patterns
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ impl TypedSemantic for RootDatabase {
|
|||
|
||||
let project_id = app_data.project_id;
|
||||
|
||||
let eqwalizer_enabled = self.is_eqwalizer_enabled(file_id, false);
|
||||
let eqwalizer_enabled = self.is_eqwalizer_enabled(file_id);
|
||||
if !eqwalizer_enabled {
|
||||
return Some(vec![]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue