Skip to content
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

New rule: NoPrintStatement #2678

Closed
arturbosch opened this issue May 12, 2020 · 4 comments · Fixed by #2753
Closed

New rule: NoPrintStatement #2678

arturbosch opened this issue May 12, 2020 · 4 comments · Fixed by #2753

Comments

@arturbosch
Copy link
Member

Expected Behavior of the rule

This rule finds all usages of standard println() or print() (System.out.println).
A logger or PrintStream facility should be used instead.

Context

Unified logging/piping output of a (command line) program.

@schalkms
Copy link
Member

This is related to the PrintStackTrace rule that detekt already has.

@cortinico
Copy link
Member

Isn't this something that can be achieved with ForbiddenMethodCall?

@BraisGabin
Copy link
Member

I agree with @cortinico. What do you think about adding kotlin.io.println() and kotlin.io.print() as default values in ForbiddenMethodCall?

@schalkms
Copy link
Member

@BraisGabin please go ahead

cortinico added a commit to cortinico/detekt that referenced this issue May 30, 2020
Adding all the variations of print/println from Java and Kotlin
to the ForbiddenMethodCall.

The rationale is to encourage the usage of a Logger.

Moreover this fixes the rule that was not catching all the method
calls due to overriding visitQualifiedExpression rather than visitCallExpression

Fixes detekt#2678
cortinico added a commit to cortinico/detekt that referenced this issue May 30, 2020
Adding all the variations of print/println from Java and Kotlin
to the ForbiddenMethodCall.

The rationale is to encourage the usage of a Logger.

Moreover this fixes the rule that was not catching all the method
calls due to overriding visitQualifiedExpression rather than visitCallExpression

Fixes detekt#2678
arturbosch pushed a commit that referenced this issue May 31, 2020
* Add default print methods to ForbiddenMethodCall

Adding all the variations of print/println from Java and Kotlin
to the ForbiddenMethodCall.

The rationale is to encourage the usage of a Logger.

Moreover this fixes the rule that was not catching all the method
calls due to overriding visitQualifiedExpression rather than visitCallExpression

Fixes #2678

* Fixing indentation

* Fixed assert location
@arturbosch arturbosch added this to the 1.10.0 milestone May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants