sonatype-lift[bot] commented on code in PR #1747:
URL: https://github.com/apache/groovy/pull/1747#discussion_r922570241
##########
src/test/groovy/transform/stc/GenericsSTCTest.groovy:
##########
@@ -1824,28 +4217,45 @@ assert result == 'ok'
'''
}
- static class MyList extends LinkedList<String> {}
+ // GROOVY-10528
+ void testRawTypeGuard() {
+ assertScript '''
+ void test(... args) {
+ args.each { object ->
+ if (object instanceof Iterable) {
+ object.each { test(it) }
+ }
+ }
+ }
+ test(1,[2,3])
+ '''
+ }
+
+
//--------------------------------------------------------------------------
+
+ static class MyList
+ extends LinkedList<String> {
+ }
- public static class ClassA<T> {
- public <X> Class<X> foo(Class<X> classType) {
+ static class ClassA<T> {
+ def <X> Class<X> foo(Class<X> classType) {
return classType;
}
-
- public <X> Class<X> bar(Class<T> classType) {
+ def <X> Class<X> bar(Class<T> classType) {
return null;
}
}
- public static class JavaClassSupport {
- public static class Container<T> {
+ static class JavaClassSupport {
+ static class Container<T> {
Review Comment:
*EmptyClass:* Class 'GenericsSTCTest$JavaClassSupport$Container' is empty
(has no methods, fields or properties). Why would you need a class like this?
Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the
above finding from this PR.
Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all
the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to **refresh** the page to see its
response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get
to know more about LiftBot commands.
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=298936507&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=298936507&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936507&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936507&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=298936507&lift_comment_rating=5)
]
##########
src/test/groovy/util/GroovyScriptEngineReloadingTest.groovy:
##########
@@ -71,22 +88,99 @@ class GroovyScriptEngineReloadingTest extends
GroovyTestCase {
gse.run("s_1", binding)
assert binding.getVariable("val") == expected
+ }
+
+ /**
+ * The script passes the className of the class it's supposed to
+ * instantiate to this method, expecting a newly instantiated object
+ * in return. The reason this is not done in the script is that
+ * we want to ensure that no unforeseen problems occur if
+ * the instantiation is not actually done inside the script,
+ * since real-world usages will likely require delegating that
+ * job.
+ */
+ private Object instantiate(String className, ClassLoader classLoader) {
+ Class clazz = null;
+ try {
+ clazz = Class.forName(className, true, classLoader);
Review Comment:
*ClassForName:* Violation in class
groovy.util.GroovyScriptEngineReloadingTest. Methods calls to
Class.forName(...) can create resource leaks and should almost always be
replaced with calls to ClassLoader.loadClass(...)
Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the
above finding from this PR.
Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all
the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to **refresh** the page to see its
response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get
to know more about LiftBot commands.
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=298936515&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=298936515&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936515&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936515&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=298936515&lift_comment_rating=5)
]
##########
src/test/org/codehaus/groovy/ast/decompiled/FieldNodeEqualityTest.groovy:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.codehaus.groovy.ast.decompiled
+
+import org.codehaus.groovy.ast.FieldNode
+import org.codehaus.groovy.control.CompilerConfiguration
+import org.junit.Test
+
+final class FieldNodeEqualityTest {
+ @Test
+ void testEquality() {
+ FieldNode fn1 = FieldNode.newStatic(CompilerConfiguration, 'JDK11')
+ assert fn1.equals(fn1)
+ FieldNode fn2 = new LazyFieldNode(() -> fn1, 'JDK11')
+ assert fn1.equals(fn2)
+ assert fn2.equals(fn1)
+ assert fn2.equals(fn2)
Review Comment:
*ComparisonWithSelf:* Comparing an object to itself is useless and may
indicate a bug: fn2.equals(fn2)
Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the
above finding from this PR.
Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all
the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to **refresh** the page to see its
response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get
to know more about LiftBot commands.
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=298936523&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=298936523&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936523&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936523&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=298936523&lift_comment_rating=5)
]
##########
src/test/org/codehaus/groovy/ast/decompiled/FieldNodeEqualityTest.groovy:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.codehaus.groovy.ast.decompiled
+
+import org.codehaus.groovy.ast.FieldNode
+import org.codehaus.groovy.control.CompilerConfiguration
+import org.junit.Test
+
+final class FieldNodeEqualityTest {
+ @Test
+ void testEquality() {
+ FieldNode fn1 = FieldNode.newStatic(CompilerConfiguration, 'JDK11')
+ assert fn1.equals(fn1)
Review Comment:
*ComparisonWithSelf:* Comparing an object to itself is useless and may
indicate a bug: fn1.equals(fn1)
Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the
above finding from this PR.
Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all
the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to **refresh** the page to see its
response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get
to know more about LiftBot commands.
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=298936522&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=298936522&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936522&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936522&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=298936522&lift_comment_rating=5)
]
##########
src/test/org/codehaus/groovy/ast/tools/WideningCategoriesTest.groovy:
##########
@@ -361,5 +374,21 @@ class WideningCategoriesTest extends GenericsTestCase {
private static class PTop<E> {}
Review Comment:
*EmptyClass:* Class 'WideningCategoriesTest$PTop' is empty (has no methods,
fields or properties). Why would you need a class like this?
Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the
above finding from this PR.
Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all
the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to **refresh** the page to see its
response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get
to know more about LiftBot commands.
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=298936528&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=298936528&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936528&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936528&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=298936528&lift_comment_rating=5)
]
##########
src/test/org/codehaus/groovy/classgen/asm/sc/DelegatesToStaticCompileTest.groovy:
##########
@@ -111,4 +111,4 @@ class DelegatesToStaticCompileTest extends
DelegatesToSTCTest implements StaticC
assert !bytecode.contains('INVOKESTATIC
org/codehaus/groovy/runtime/ScriptBytecodeAdapter.castToType')
Review Comment:
*AssertWithinFinallyBlock:* A finally block within class
org.codehaus.groovy.classgen.asm.sc.DelegatesToStaticCompileTest contains an
assert statement, potentially hiding the original exception, if there is one
Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the
above finding from this PR.
Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all
the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to **refresh** the page to see its
response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get
to know more about LiftBot commands.
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=298936538&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=298936538&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936538&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936538&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=298936538&lift_comment_rating=5)
]
##########
src/test/org/codehaus/groovy/classgen/asm/sc/FieldsAndPropertiesStaticCompileTest.groovy:
##########
@@ -564,20 +590,20 @@ import
org.codehaus.groovy.transform.sc.ListOfExpressionsExpression
void
testCallMultiSetterAsPropertyWithinFinallyBlockShouldNotThrowVerifyError() {
try {
assertScript '''
- class Multi {
- void setOut(int a) {}
- void setOut(String a) {}
- }
+ class Multi {
+ void setOut(int a) {}
+ void setOut(String a) {}
+ }
- void foo() {
- def m = new Multi()
- try {
- } finally {
- m.out = 1
- m.out = 'foo'
- }
- }
- foo()
+ void foo() {
+ def m = new Multi()
+ try {
+ } finally {
+ m.out = 1
+ m.out = 'foo'
+ }
+ }
+ foo()
'''
} finally {
assert astTrees.values().any {
Review Comment:
*AssertWithinFinallyBlock:* A finally block within class
org.codehaus.groovy.classgen.asm.sc.FieldsAndPropertiesStaticCompileTest
contains an assert statement, potentially hiding the original exception, if
there is one
Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the
above finding from this PR.
Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all
the findings from this PR and from the status bar in Github.
When talking to LiftBot, you need to **refresh** the page to see its
response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get
to know more about LiftBot commands.
---
Was this a good recommendation?
[ [🙁 Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=298936540&lift_comment_rating=1)
] - [ [😕 Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=298936540&lift_comment_rating=2)
] - [ [😑 Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936540&lift_comment_rating=3)
] - [ [🙂 Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=298936540&lift_comment_rating=4)
] - [ [😊 Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=298936540&lift_comment_rating=5)
]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]