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

Replace JSONObject's opt functions with nullable extensions #1815

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

jreij
Copy link
Collaborator

@jreij jreij commented Oct 9, 2024

Description

  • Replace JSONObject's opt functions (optString, optBoolean, optInt, optLong and optDouble) with nullable extensions. These functions are non nullable and return arbitrary default values which could cause unexpected bugs.
  • Add a lint rule to prevent their use.

Checklist

  • PR is labelled
  • Code is unit tested
  • Changes are tested manually

COAND-1003

@jreij jreij added the Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes label Oct 9, 2024
@jreij jreij requested a review from a team as a code owner October 9, 2024 11:11
@jreij jreij marked this pull request as draft October 9, 2024 11:11
null instead.
""".trimIndent().replace(Regex("(\n*)\n"), "$1"),
implementation = Implementation(JSONOptFunctionsDetector::class.java, Scope.JAVA_FILE_SCOPE),
category = Category.I18N,
Copy link
Contributor

Choose a reason for hiding this comment

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

CUSTOM_LINT_CHECKS is a better category I think

…n, optInt, optLong and optDouble

These functions are non nullable and return arbitrary default values which could cause unexpected bugs. We should use our internal extension functions that return null instead
COAND-1003
The opt functions are non nullable and return arbitrary default values which could cause unexpected bugs
COAND-1003
Copy link

✅ No public API changes

Copy link

sonarcloud bot commented Oct 10, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
14.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants