-
Notifications
You must be signed in to change notification settings - Fork 1k
Split out camel experimental assertions #14433
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
Split out camel experimental assertions #14433
Conversation
buildscripts/checkstyle.xml
Outdated
<module name="RegexpSinglelineJava"> | ||
<property name="format" | ||
value="(?<!import static io.opentelemetry.sdk.testing.assertj.)OpenTelemetryAssertions\."/> | ||
value="(?<!import (?:static )?io.opentelemetry.sdk.testing.assertj.)OpenTelemetryAssertions\.(?![A-Z]\w*[;\s]*)"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex is too strict and catching inner classes, which in this case can't be statically imported. I updated the pattern to exclude both regular and static imports from the package, and to allow uppercase class names while still catching lowercase method calls that should be statically imported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is quite hard to understand - can we make it 2 assertions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i simplified it a bit
<module name="RegexpSinglelineJava"> | ||
<property name="format" | ||
value="(?<!import static io.opentelemetry.sdk.testing.assertj.)OpenTelemetryAssertions\."/> | ||
value="^(?!.*import).*OpenTelemetryAssertions\.[a-z]"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need a negative lookahead here? would it work without?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the negative lookback it catches lines like import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
[ant:checkstyle] [WARN] /Users/jaydeluca/code/projects/opentelemetry-java-instrumentation/instrumentation/ca
mel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/ExperimentalTest.jav
a:8: Please statically import methods from OpenTelemetryAssertions [RegexpSinglelineJava]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, got it now - maybe it's worth to add a comment explaining that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added a comment here, do you have a suggestion on how it could be more clear? I tried to explain it with the
but allow inner classes (uppercase) and imports
<module name="RegexpSinglelineJava"> | ||
<property name="format" | ||
value="(?<!import static io.opentelemetry.sdk.testing.assertj.)OpenTelemetryAssertions\."/> | ||
value="^(?!.*import).*OpenTelemetryAssertions\.[a-z]"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value="^(?!.*import).*OpenTelemetryAssertions\.[a-z]"/> | |
<!-- negative lookahead for "import", because imports are handled by the rule below --> | |
value="^(?!.*import).*OpenTelemetryAssertions\.[a-z]"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rule below is only for assertThat
methods, but I pushed an update that calls out the lookahead being to exclude imports
Related to #14128, part of #13468
Created a separate test suite for experimental attributes and enabled telemetry collection.
the checkstyle task was failing with:
The regex is too strict and catching inner classes, which in this case can't be statically imported. I updated the pattern to exclude both regular and static imports from the package, and to allow uppercase class names while still catching lowercase method calls that should be statically imported.