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

[ContractHandler] Handle @Contract with empty value. #450

Merged
merged 3 commits into from
Feb 22, 2021

Conversation

lazaroclapp
Copy link
Collaborator

The IntelliJ @Contract annotation has two fields, value
and pure. When pure = true, value can be left empty.
As such, the following is a valid @Contract annotation:

@Contract(
  pure = true
)

See. https://www.jetbrains.com/help/idea/contract-annotations.html

Here, retriving the annotation value produces an empty
string.

However, existing ContractHandler logic expects value to
either be null or a properly formated string in
IntelliJ contract syntax ("[...] -> [...]; [...]").

Previous to this change, NullAway would report an error
AND crash when seeing the @Contract annotation above,
rather than ignore it. This patch fixes this.

The IntelliJ `@Contract` annotation has two fields, `value`
and `pure`. When `pure = true`, `value` can be left empty.
As such, the following is a valid `@Contract` annotation:

```
@contract(
  pure = true
)
```

See. https://www.jetbrains.com/help/idea/contract-annotations.html

Here, retriving the annotation value produces an empty
string.

However, existing ContractHandler logic expects `value` to
either be `null` or a properly formated string in
IntelliJ contract syntax (`"[...] -> [...]; [...]"`).

Previous to this change, NullAway would report an error
AND crash when seeing the `@Contract` annotation above,
rather than ignore it. This patch fixes this.
@lazaroclapp
Copy link
Collaborator Author

Found while testing #446 , blocker. Will add a test in a moment.

Copy link
Collaborator

@msridhar msridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming we will add a test

@coveralls
Copy link

coveralls commented Feb 22, 2021

Pull Request Test Coverage Report for Build #474

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.144%

Totals Coverage Status
Change from base Build #470: 0.0%
Covered Lines: 3457
Relevant Lines: 3878

💛 - Coveralls

@lazaroclapp lazaroclapp merged commit 875cf56 into master Feb 22, 2021
@lazaroclapp lazaroclapp deleted the lazaro_fix_contract_handler_for_pure branch February 22, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants