Summary:
We may want to disable a linter for a certain set of applications. This diff introduces such a mechanism:
```
[linters.my_linter]
exclude_apps = ["app_a", "app_2"]
```
Reviewed By: alanz
Differential Revision: D89658976
fbshipit-source-id: 78e1cf13ec22f1bf7ed1b6df6892cdad5ca2dfe5
Summary: Missed during the original rename.
Reviewed By: alanz
Differential Revision: D89460380
fbshipit-source-id: 60446aa3f505d635ad5ddc842b2d420c24f0a9d2
Summary:
We already have a feature to understand if Buck2 is enabled or not. Let's use that one instead of a constant.
This change has no effect anyway since the only two use cases are currently marked as "ignored".
Also remove the extra check inside the helper (we already do it in both tests).
Reviewed By: alanz
Differential Revision: D89549782
fbshipit-source-id: 82e5bbf00c463dca3f4937d2d2a12d16aebc3c19
Summary:
The test projects are now standalone, so the Buck2 tests can be enabled in CI.
Two major fixes to the tests:
* Use the project directory to calculate the project root (there's no `.buckconfig` for the ELP crate as a whole in OSS)
* Fix expectations for the Buck2 errors (no URL in OSS)
Reviewed By: alanz
Differential Revision: D89547047
fbshipit-source-id: 76fa8bcc1fadabbeb9ea59245d36d2aacd98a023
Summary: We want to enable Buck2 tests on GitHub. This requires a bit of groundwork.
Reviewed By: michalmuskala
Differential Revision: D88959148
fbshipit-source-id: e5f88f561e061635aae05c4e3bc22382771a8908
Summary:
In non-test Erlang code, the following is almost always intended as assignment of a value to the LHS variable
```
Var = expr()
```
It is actually a match, and may fail if `Var` is already bound, and the new value differs from the old.
This diff introduces a diagnostic to warn of this case.
Reviewed By: robertoaloi
Differential Revision: D89374198
fbshipit-source-id: 19dcee50ad6e71d0a606a0eb6cf548b7194d61e6
Summary:
The linter is enabled by default in ELP, and warnings appear in the IDE.
But the same linter is not explicitly added to the CI configuration, so warnings are not reported on diffs or in Contlint.
This diff enables the linter, aligning the IDE and the CI experience. It also makes it possible to track violations via ContLint.
We exclude known false positives via config.
Ideally, we would like to report undefined functions in all files, but there are too many false positives in test files to do so.
This is often due to mocked modules and test suite cleverness. We can revisit this decision in the future. See T249044930 for details.
We disable the linter for tests both in the default value (for the future) and the config (so we don't need to wait for a ELP release to land this change).
Reviewed By: alanz
Differential Revision: D89393641
fbshipit-source-id: bfb9ac760ba79566301087033af95bb805fdeaa0
Summary: The old name was too generic, and could be mis-interepreted as an EDoc linter (a linter that verifies EDoc syntax). By aligning the name of the linter with the actual diagnostic code, we make the intention more clear. No functional change.
Reviewed By: alanz
Differential Revision: D89374941
fbshipit-source-id: bf8518ed9602bdceca2fcbf3ddb00990f56af529
Summary:
Documentation is generally not produced for test files, so do not run the `old_edoc_syntax` linter for tests. If not, edoc references in tests should be converted to plain comments, not to `-moduledoc` or `-doc` attributes.
This behaviour can always be overwritten by setting the `severity` or the `include_tests` properties of the linter via config.
Reviewed By: alanz
Differential Revision: D89374552
fbshipit-source-id: 8a4299fcbd16a82f62efbc14f47fef46cd08fbc0
Summary:
Some clients, such as emacs eglot, do their own project discovery when a new file is opened, even from the target of a go to definition.
They then launch a fresh ELP server if they determine a different project root.
In the ELP server setup we preconfigure the OTP project root as known, but with a project manifest of None. This means go to def into an OTP file ends up with an uninitialized project in the new server.
This diff makes it so that if the project root is known, but has no project manifest, we do discovery on that root.
Pull Request resolved: https://github.com/whatsapp/erlang-language-platform/pull/141
Reviewed By: robertoaloi
Differential Revision: D89169465
Pulled By: alanz
fbshipit-source-id: db180d67df98fd1f1fd61a53a93f9adfa9e93ebd
Summary:
Remove the tag `OTPVersionDependent` which created one expected result per OTP version per snapshot.
Instead, use `OTPXXOnly` (where `XX` is a version number), that skips checks for OTP versions that are not `XX`.
In practice, it's used as `OTP27Only` for now.
Reviewed By: michalmuskala, TD5
Differential Revision: D89378687
fbshipit-source-id: 0421622d825ac4e8f393d32529c01eb17577b5e5
Summary:
Fix two bugs for `--no-stream` for `elp lint`
1. args.skip_stream_print() now skips if either the flag is set, or `--apply-fixes` is set
2. When we are not streaming, and also not applyiing fixes, print the diagnostics
Reviewed By: robertoaloi
Differential Revision: D89369072
fbshipit-source-id: 2279aca861fb09c5b33adb0000e3a58821026064
Summary: Add a test demonstrating that the module rename happens in `.hrl` files too
Reviewed By: TheGeorge
Differential Revision: D89053579
fbshipit-source-id: f999484c08a5c33c76986156c10a2f6a7d34fc52
Summary:
Simplify the rename module logic to use the standard approach, find usages, rename each of them.
And in the process ensure that remote calls in the module being renamed are also renamed.
Reviewed By: robertoaloi
Differential Revision: D88947976
fbshipit-source-id: c703be8392b7ac634ced2c45d8553d33882d460b
Summary:
Certain functions are known to take a module name as an argument. We already have a list of those that correspond to referencing a function as an MFA, in `to_def.rs`. We extend this with some other examples, and check for renaming them too as part of the module rename.
The list is currently incommplete, and can be filled out based on usage. A future diff may look at ways of generating it from `-spec` information.
Reviewed By: robertoaloi
Differential Revision: D88943301
fbshipit-source-id: 05c67a108b1dc5b64f4353872427361fd039171f
Summary:
When identifying a call from a reference, we start from the ast token for the module name, and ascend the ast until we find a call.
But up to now we have not checked that the module we started from is the module part of the call MFA.
This diff adds that check.
Reviewed By: robertoaloi
Differential Revision: D88934411
fbshipit-source-id: 81a57520ec834210fcea8fd6920653cc45f9890c
Summary: A module name can occur in an external fun. Rename it too.
Reviewed By: robertoaloi
Differential Revision: D88849514
fbshipit-source-id: e715628a6fbfe419cd56761fe62b43d3b68ecde4
Summary:
The final step in renaming a module. Move the old file, and apply the needed edits to it.
This diff also simplifies the mechanics of the rename, to be more general and in line with other renames, by iterating over usages of the module, rather than ad-hoc checks for things that may be needed.
It is still ad-hoc, in the sense that it only looks for call-like things at the moment (fully qualified calls and types). Other usages will come in later diffs
Reviewed By: robertoaloi
Differential Revision: D87861050
fbshipit-source-id: d393638b310a257f51151fc3caf1b1445c856700
Summary: When renaming a module, rename all references to types within it
Reviewed By: robertoaloi
Differential Revision: D87860496
fbshipit-source-id: 2ac6bc52cecaef6802fcf9f181b638f81c556d67
Summary:
Rename references to functions exported from a module when the module is renamed.
This requires fleshing out the infrastructure to deal with deleting files too.
Reviewed By: robertoaloi
Differential Revision: D87860436
fbshipit-source-id: b4d04eb0cfc6448a407fa8c3202ef3e4e088b7e8
Summary: First case, just rename the module
Reviewed By: robertoaloi
Differential Revision: D87860412
fbshipit-source-id: 0427f09bd2176778e0280b0f45f9331fa279f778
Summary:
This diff stack introduces rename for a module. As this is a complex operation, it will be done in steps.
The first one is to put the basics in place
- check the new name is valid
- Improve rename test fixture to cope with added and renamed files
Reviewed By: robertoaloi
Differential Revision: D87860388
fbshipit-source-id: 1a240a5e0e5e61d5c128bca0423744f001b7b68d
Summary:
The `mutable_variable` diagnostic processed bound variables organised by function.
We intend doing the same for more bound variable diagnostics, so as a precursor extract this a method we can call on `Semantic`
Reviewed By: TD5
Differential Revision: D89270590
fbshipit-source-id: 95a520d45e900c0a5c97fd8163cbaedbc15ca840
Summary:
When folding with visible macros, we keep track of a macro stack, so we can decide how to process diagnostics within the body of a macro expansion.
To date we have simply stored the `HirIdx` of the macro call, so it can be retrieved and examined by anything that needs it.
But the thing we need when processing a macro is in fact what definition was expanded. This diff adds it to the information stored for easy access.
It will be used in a subsequent diff.
Reviewed By: TD5
Differential Revision: D89269840
fbshipit-source-id: 7ed6212b658de91cdd3e20701edb51161966e8fa
The internal and external repositories are out of sync. This Pull Request attempts to brings them back in sync by patching the GitHub repository. Please carefully review this patch. You must disable ShipIt for your project in order to merge this pull request. DO NOT IMPORT this pull request. Instead, merge it directly on GitHub using the MERGE BUTTON. Re-enable ShipIt after merging.
fbshipit-source-id: a4e36831ac3939cb9a4881ca077b5f8c0d421104
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
Summary: It is common for the `fixes` callback to act on the original match range. By making the matched range available to the callback, we avoid manually including the range in the linter-specific context.
Reviewed By: alanz
Differential Revision: D89048282
fbshipit-source-id: 01faa9842f04c34efb14a7d803cf5317794ea321
Summary:
Use new error message generation for callback type errors, add corresponding test
Cleanup old error message generation
Reviewed By: TD5
Differential Revision: D88941623
fbshipit-source-id: 262c2031c7d19ad2528ef63a5d73d146fd84d408
Summary:
Apply the severity filter to the results before printing any information about them.
This prevents printing a module name that has no errors in it, and gives a correct count in the module diagnostic summary
Reviewed By: TD5
Differential Revision: D89043311
fbshipit-source-id: aa0c813314f32ca9c23d753c598974a1eb605390
Summary: Occurrence typing doesn't take place in `maps:foreach` (and several other custom functions). Repro.
Reviewed By: michalmuskala
Differential Revision: D88949717
fbshipit-source-id: d6225a708f0c632d914c4ca38b1d789a3b077311
Summary:
The test is supposed to panic (and does so) when run with both Buck2 and rebar3.
Unfortunately, we are currently disabling the Buck2 tests on GitHub, which has the unfortunate consequence of not letting the test fail as expected, effectively breaking CI.
Temporarily ignore the test.
Reviewed By: alanz
Differential Revision: D88950046
fbshipit-source-id: edabc83ce2b533fa95075078feac624343c198ad
Summary:
The previous diff added the ability to validate a test fixture for parse errors, with an override mechanism if they are expected.
This diff enables the validation for all fixture parsing, and fixes all the resulting errors.
Reviewed By: TD5
Differential Revision: D88948727
fbshipit-source-id: c7e584f3e63c5ad095b9602eed56b469a73392d2
Summary:
A common mistake when writing a declarative test fixture is to have a syntax error in it.
This diff adds `ChangeFixture::validate` to check for these, and panic if found, e.g.
```
thread 'tests::validate_fixture_with_parse_error' panicked at crates/ide_db/src/lib.rs:462:17:
Fixture validation failed: syntax errors found in test fixture
File: /src/test.erl
Errors: [Missing(")", 19..19)]
Content:
-module(test).
foo( -> ok.
Parse Tree:
SourceFile {
syntax: SOURCE_FILE@0..27
MODULE_ATTRIBUTE@0..14
ANON_DASH@0..1 "-"
ANON_MODULE@1..7 "module"
ANON_LPAREN@7..8 "("
ATOM@8..12
ATOM@8..12 "test"
ANON_RPAREN@12..13 ")"
ANON_DOT@13..14 "."
WHITESPACE@14..15 "\n"
FUN_DECL@15..26
FUNCTION_CLAUSE@15..25
ATOM@15..18
ATOM@15..18 "foo"
EXPR_ARGS@18..19
ANON_LPAREN@18..19 "("
WHITESPACE@19..20 " "
CLAUSE_BODY@20..25
ANON_DASH_GT@20..22 "->"
WHITESPACE@22..23 " "
ATOM@23..25
ATOM@23..25 "ok"
ANON_DOT@25..26 "."
WHITESPACE@26..27 "\n"
,
}
---
If this is expected, add `//- expect_parse_errors` to the start of the fixture
```
A subsequent diff will apply it to the code base
Reviewed By: TD5
Differential Revision: D88948352
fbshipit-source-id: 532275075bb338191594966bb3292986442cead6
Summary:
A declarative test fixture can have multiple files in it, in which case each has a metadata line giving the file name. But we have not been checking if it is omitted from the first file, leading to confusing behaviour when writing tests.
This diff updates test fixture parsing to panic in that case, with an appropriate message.
Reviewed By: TD5
Differential Revision: D88947477
fbshipit-source-id: 7ef7151fafb44d087b1da25c55454f20899ca67f
Summary:
As title.
Note that this is still failing on GH.
Reviewed By: robertoaloi
Differential Revision: D88751685
fbshipit-source-id: 4050a9f2094ac7c46395f0f05a7f77dfad9a583b
Summary: Move the decision-making logic for choosing to output color in CLI usage into a single place.
Reviewed By: TD5
Differential Revision: D88377007
fbshipit-source-id: 398552dba1547a9e9c0b5e6cd38808316280dd7a
Summary:
Measurements show it makes no difference to the run-time of `elp eqwalize-all`, and it is an impediment to providing streaming output.
Without this, parsing happens on-demand as files are processed by eqwalizer, so we can generate output as each is processed.
Reviewed By: robertoaloi
Differential Revision: D88379872
fbshipit-source-id: 5110788ac5a7ef471038db9de0abfa00bbe7312f
Summary:
At the moment the `elp lint` command processes all the files, and then renders the diagnostics at the end. This can be annoying if you are wanting to just check for occurrences of a diagnostic.
This diff changes the behaviour to stream the results instead as they arrive.
This behaviour is turned off if
- the new `--no-stream` argument is given
- `elp lint` emits json formatted diagnostics
- `elp lint` applies fixes
Reviewed By: TheGeorge
Differential Revision: D88010824
fbshipit-source-id: dc725c1d503f56da6bb1c392cd88f635832320dc
Summary: As title. Remove the "detailed message" part, which is too verbose and mostly useless now.
Reviewed By: TD5
Differential Revision: D88633277
fbshipit-source-id: 092691c2520983148fa0ef8d61a62bd1149a1231
Summary: Mechanical conversion. I also removed the "related info" since they did not seem to provide any additional benefit.
Reviewed By: TD5
Differential Revision: D88379801
fbshipit-source-id: 10926fdc31b88b5755ff346f97948cf83569f71e