-
Notifications
You must be signed in to change notification settings - Fork 73
Add NoAsyncRunSynchronouslyInLibrary rule #785
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
Conversation
tests/FSharpLint.Core.Tests/Rules/Conventions/NoAsyncRunSynchronouslyInLibrary.fs
Show resolved
Hide resolved
src/FSharpLint.Core/Rules/Conventions/NoAsyncRunSynchronouslyInLibrary.fs
Outdated
Show resolved
Hide resolved
8fbe79e to
43fa62a
Compare
But we don't want the check to be just about the file but about the whole assembly. |
The whole assembly check will only work when linting project or solution. |
I know. That's why we don't recommend (show a warning) when only linting files. |
|
BTW, in my comment (#785 (comment)) I'm quoting some text from a commit msg, that either should be fixed (changed the wording), or implemented properly. |
After you have fixed the above, let's add 2 more commits:
|
75e8b61 to
b83aebd
Compare
b49d71b to
baecfb8
Compare
d562060 to
5f894e7
Compare
ceb92d0 to
36609bd
Compare
No checks for assembly name yet.
Check assembly name. If it contains "test" substring, assume this is test project and don't fire the rule.
For NoAsyncRunSynchronouslyInLibrary rule that make sure that code inside NUnit and MSTest tests doesn't trigger the rule. Includes failing tests.
Check if Async.RunSynchronously call is iniside NUnit or MSTest tests. If it is, don't trigger the rule.
Add configuration for the rule and enable it by default.
Assembly.QualifiedName is empty, so instead check namespace and project name.
Simplified check for entry point. Also combined some code that uses args.CheckInfo to not pattern match on it twice.
That also calls `Async.RunSynchronously` and causes CI to fail.
Got rid of Async.RunSynchronously calls in FSharpLint.Core.
7ccd5b9 to
37ea50e
Compare
|
let's squash commit
|
Exclude projects that have "console" in their name addition to those that contain "test".
Updated docs for NoAsyncRunSynchronouslyInLibrary to make clear what code is considered to be library code.
When linting project. This will give more information for rules to use, such as all types defined in an assembly.
For EntryPoint point attribute instead of just current file.
Added 2 more tests for NoAsyncRunSynchronouslyInLibrary rule.
Make rule pass new tests by checking all nodes in the file for test attributes, not only parent nodes. Also when checking a project, check all files in the project for classes that are marked by test attributes.
That were removed in commit 9de63ea ("Core,Console,Tests: refactoring").
Methods and functions when applying the rule. Added 2 more tests. Marked non-async parsing methods re-introduced in previous commit with `[<Obsolete>]` attribute.
To address feedback.
Use new function `howLikelyProjectIsTestOrLibrary` instead of `isInTestProject` and made unit tests for this function.
Category, because its violations are more like a mistake, not a deviation from a certain standard. Also moved Smells folder down in the project, because NoAsyncRunSynchronouslyInLibrary depends on function from NamingHelpers, and that module is in Conventions/Naming. Conventions folder was above Smells, which made NamingHelpers inaccessible to NoAsyncRunSynchronouslyInLibrary.
694c27a to
df906fd
Compare
8785731 to
64f25ef
Compare
In addition to class attribute when checking file declarations to decide if the class is test class because in later NUnit versions it is optional to mark the class, only methods must be marked with test attribute.
64f25ef to
0ea5daa
Compare
Added new NoAsyncRunSynchronouslyInLibrary rule and tests for it.