Skip to content

Commit

Permalink
Update warning message for "MissingNavigationDestinationAnnotation"
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-udy committed Nov 15, 2024
1 parent f55f145 commit 2de8c1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion enro-lint/src/main/java/dev/enro/lint/EnroIssueDetector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class EnroIssueDetector : Detector(), Detector.UastScanner {
context.report(
issue = missingNavigationDestinationAnnotationCompose,
location = context.getLocation(node),
message = "${composableParent.name} is not marked as a NavigationDestination.\nRequesting a TypedNavigationHandle in this way may be cause a crash if ${composableParent.name} is called from a NavigationDestination that is not bound to '${navigationHandleGenericType.presentableText}'",
message = "@Composable function '${composableParent.name}' is not annotated with '@NavigationDestination(${navigationHandleGenericType.presentableText})'",
quickfixData = fix()
.name("Add NavigationDestination to ${composableParent.name}")
.replace()
Expand Down
7 changes: 6 additions & 1 deletion enro-lint/src/main/java/dev/enro/lint/Issues.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ val missingNavigationDestinationAnnotation = Issue.create(
val missingNavigationDestinationAnnotationCompose = Issue.create(
id = "MissingNavigationDestinationAnnotation",
briefDescription = "Missing Navigation Destination Annotation",
explanation = "Attempting to create a NavigationHandleProperty inside a Composable that is not marked as a NavigationDestination",
explanation = "Requesting a TypedNavigationHandle here may cause a crash, " +
"as there is no guarantee that the nearest NavigationHandle has a NavigationKey of the requested type.\n\n" +
"This is not always an error, as there may be higher-level program logic that ensures this will succeed, " +
"but it is important to understand that this works in essentially the same way as an unchecked cast. " +
"If you do not need a TypedNavigationHandle, you can request an untyped NavigationHandle by removing the type" +
"arguments provided to the `navigationHandle` function",
category = Category.PRODUCTIVITY,
priority = 5,
severity = Severity.WARNING,
Expand Down

0 comments on commit 2de8c1c

Please sign in to comment.