You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Some Java APIs have instance methods that are discouraged.
For example when using the Playwright Java API, the Locator class has many methods which are inherently flaky
and should not be used in tests.
It would be good to be able to configure those per project so that you don't accidentally use a discouraged
method, when better alternatives exist.
Describe the solution you'd like
A :discouraged-instance-method linter that would warn about specific. Class & method combination.
Similar to :discouraged-var for Clojure.
Describe alternatives you've considered
You can always use existing Clojure libraries that wrap Java APIs when such exist or provide project specific wrappers.
That doesn't prevent you from dropping down to Java interop and using it directly.
Additional context
Configuring the hypothetical linter with
{:linters {:discouraged-instance-method {com.microsoft.playwright.Locator/all {:message "Flaky method! Use PlaywrightAssertions API."}}}}
And having the following code:
(nsplaywright-all
(:import (com.microsoft.playwright Locator)
(com.microsoft.playwright.assertions PlaywrightAssertions)
(org.opentest4j AssertionFailedError)))
(defnhas-n-elements-flaky [^Locator locator n]
;; .all is inherently flaky, should not be used
(= n (count (.all locator))))
(defnhas-n-elements-correct [^Locator locator n]
;; Correct t
(try
(-> locator PlaywrightAssertions/assertThat
(.hasCount n))
true
(catch AssertionFailedError _afe
false)))
would issue a warning on the .all call on line 8.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Some Java APIs have instance methods that are discouraged.
For example when using the Playwright Java API, the Locator class has many methods which are inherently flaky
and should not be used in tests.
It would be good to be able to configure those per project so that you don't accidentally use a discouraged
method, when better alternatives exist.
Describe the solution you'd like
A
:discouraged-instance-method
linter that would warn about specific. Class & method combination.Similar to
:discouraged-var
for Clojure.Describe alternatives you've considered
You can always use existing Clojure libraries that wrap Java APIs when such exist or provide project specific wrappers.
That doesn't prevent you from dropping down to Java interop and using it directly.
Additional context
Configuring the hypothetical linter with
And having the following code:
would issue a warning on the
.all
call on line 8.The text was updated successfully, but these errors were encountered: