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

ThrowingExceptionInMain rule should consider main() function with no parameters #2248

Closed
schalkms opened this issue Jan 11, 2020 · 0 comments · Fixed by #2240
Closed

ThrowingExceptionInMain rule should consider main() function with no parameters #2248

schalkms opened this issue Jan 11, 2020 · 0 comments · Fixed by #2240
Milestone

Comments

@schalkms
Copy link
Member

As of Kotlin 1.3, the explicit Array can be omitted but will still be available in the byte code.
Reference

Expected Behavior

The rule should also flag parameterless main() functions that throw an exception.

fun main() { throw IllegalArgumentException() }

Observed Behavior

The rule ignores parameterless main() functions.

Your Environment

  • Version of detekt used: 1.3.1
  • Operating System and version: macOS 10.14.6
3flex pushed a commit that referenced this issue Jan 12, 2020
* Add tests for ThrowingExceptionInMain rule

* Update test case to throw exception inside main()

* Update test description (grammar)

* Consider parameterless main() in ThrowingExceptionInMain rule

Fixes #2248

* Add tests for parameterless main() and for some negative cases

* Refactor duplicated condition in isMainFunction()

This commit also fixes a codefactor warning.

* Add test for top level main with expression body
@arturbosch arturbosch added this to the 1.4.0 milestone Jan 12, 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.

2 participants