You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2022/09/21 14:20:55 UTC
[GitHub] [groovy] Shadow-Devil opened a new pull request, #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Shadow-Devil opened a new pull request, #1785:
URL: https://github.com/apache/groovy/pull/1785
Consider the following:
```
@groovy.transform.TypeChecked
void test(int[] ints) {
ints.eachWithIndex { value, index ->
println "$index: ${value.doubleValue()}"
}
}
test(0,1,2,3,4,5)
Compiler reports "[Static type checking] - Cannot find matching method java.lang.Object#doubleValue()"
```
`eachWithIndex` is only provided for reference types, so "value" is seen as Object by the type checker.
Currently, only a draft for int arrays. Should probably also be implemented for other primitive types.
There are three different approaches to do this:
1. Copy-paste the implementation for each overload
2. Delegate to `eachWithIndex(Iterable<T> self, Closure closure)`
3. Delegate to `eachWithIndex(Iterator<T> self, Closure closure)`
I found option three most appealing since option 1 adds unnecessary code duplication and option 2 just calls option 3 with the iterator of `self` which would add unnecessary overhead.
https://issues.apache.org/jira/browse/GROOVY-10682
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] Shadow-Devil commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
Shadow-Devil commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r979319778
##########
src/spec/test/typing/TypeCheckingTest.groovy:
##########
@@ -44,6 +44,23 @@ class TypeCheckingTest extends StaticTypeCheckingTestCase {
'''
}
+ void testTypeCheckedEachWithIndex(){
+ //TODO: tags?
Review Comment:
Thank you very much for your help. I think I will add a simple test case here https://github.com/apache/groovy/blob/master/src/spec/test/gdk/WorkingWithArraysTest.groovy
that also works without my extension
and one with stc into here https://github.com/apache/groovy/blob/master/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy#L28-L40 that only works if we add the extension. Otherwise, I think it would be quite weird for the reader of the doco to see a method annotated with `@groovy.transform.TypeChecked`.
One small note: I thought the doco file should be about arrays, but in the second paragraph you are talking about "Iterating on a list". Is this a maybe typo?
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976833809
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2294,31 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int[] nums = [5, 4, 3]
+ * String result = ''
+ * nums.eachWithIndex{ num, index -> result += "$index:${num + 1}" }
Review Comment:
*[UnescapedEntity](https://errorprone.info/bugpattern/UnescapedEntity):* This HTML entity is invalid. Enclosing the code in this <pre>/<code> tag with a {@code } block will force Javadoc to interpret HTML literally.
---
```suggestion
* <pre class="groovyTestCase">{@code
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=335558942&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=335558942&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=335558942&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=335558942&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=335558942&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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r977080247
##########
src/spec/test/typing/TypeCheckingTest.groovy:
##########
@@ -44,6 +44,23 @@ class TypeCheckingTest extends StaticTypeCheckingTestCase {
'''
}
+ void testTypeCheckedEachWithIndex(){
+ //TODO: tags?
Review Comment:
Tests like this either belong here if they appear as part of the documentation in which case we'd also add the documentation and tags or we'd put them somewhere like:
https://github.com/apache/groovy/blob/master/src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy#L28-L40
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976634392
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
+ * assert result == 5
+ * </pre>
+ *
+ * @param self an int array
+ * @param closure a Closure to operate on each item
+ * @return the self Object
+ * @since 1.0
Review Comment:
Set the since value to 5.0.0
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r980526924
##########
src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java:
##########
@@ -0,0 +1,85 @@
+package org.codehaus.groovy.runtime;
+
+import groovy.lang.Closure;
+import groovy.transform.stc.ClosureParams;
+import groovy.transform.stc.FirstParam;
+import groovy.transform.stc.FromString;
+
+/**
+ * This class defines new groovy methods which appear on prrimitive arrays inside the Groovy environment.
Review Comment:
type in 'prrimitive'
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r977081335
##########
src/spec/test/typing/TypeCheckingTest.groovy:
##########
@@ -44,6 +44,23 @@ class TypeCheckingTest extends StaticTypeCheckingTestCase {
'''
}
+ void testTypeCheckedEachWithIndex(){
+ //TODO: tags?
Review Comment:
The current best fit for such doco would currently be core-syntax.adoc or core-semantics.adoc but I'll make a separate "working with arrays" subsection in the gdk doco since it would really belong there.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1253853185
This is a good start. I added some notes on the commit. You should compare to the javadoc for the `T[]` variant and try to match it, except here you know the array element type so you may be able to make some small improvements.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] Shadow-Devil commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
Shadow-Devil commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976783483
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
Review Comment:
I'm not sure how the debugging works, since I can't place the breakpoint inside the javadocs and I don't think I should step through all of the test cases.
I changed the test case to:
```
int[] nums = [5, 4, 3]
String result = ''
nums.eachWithIndex{ num, index -> result += "$index:${num + 1}" }
assert result == '0:61:52:4'
```
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1253871209
If we're adding `eachWithIndex` it appears we also need `each` to satisfy STC. Can you add an `each(int[])` as well?
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r984915395
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
- return join(new BooleanArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of byte
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(byte[] self, String separator) {
- return join(new ByteArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of char
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(char[] self, String separator) {
- return join(new CharArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of double
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(double[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737779&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737779&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737779&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737779&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737779&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
- return join(new BooleanArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of byte
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(byte[] self, String separator) {
- return join(new ByteArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of char
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(char[] self, String separator) {
- return join(new CharArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of double
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(double[] self, String separator) {
- return join(new DoubleArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of float
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(float[] self, String separator) {
- return join(new FloatArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of int
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(int[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737790&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737790&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737790&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737790&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737790&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the byte array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(byte[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the char array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(char[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the double array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(double[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the float array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(float[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the int array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(int[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the long array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(long[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the short array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(short[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737805&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737805&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737805&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737805&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737805&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
- return join(new BooleanArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of byte
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(byte[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737835&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737835&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737835&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737835&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737835&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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] Shadow-Devil commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
Shadow-Devil commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r981093151
##########
src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy:
##########
@@ -37,6 +37,20 @@ class DefaultGroovyMethodsSTCTest extends StaticTypeCheckingTestCase {
println it // DGM#println(Object,Object)
}
'''
+
+ assertScript '''
+ int[] nums = [0, 1]
+ nums.each { it -> // ArrayGroovyMethods#each(int[], Closure)
+ println it.toDouble() // DGM#println(Object,Object)
Review Comment:
I think I would stop writing tests in this test class and only use the tests inside the Javadoc since otherwise the number of tests would explode for ~60 methods with each 8 primitive types (roundabout 480 tests).
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert merged pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert merged PR #1785:
URL: https://github.com/apache/groovy/pull/1785
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976635917
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
+ * assert result == 5
+ * </pre>
+ *
+ * @param self an int array
+ * @param closure a Closure to operate on each item
Review Comment:
You could replace "item" with integer or number since you know the array element type.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1255602797
We have used code generators (hand-hacked throwaway Groovy scripts) from time to time to generate repeated patterns.
We could enhance both the dynamic and static behaviours to do some kind of array-level "auto-unboxing" for T[] and the like but we have opted not to in the past for better Java integration and (at the time) efficiency with the hand-coded primitive variants likely to be more efficient.
We also have `IntArrayIterable` (and Long/Double variants). So we could write:
```
public static int[] eachWithIndex(int[] self, @ClosureParams(value=FromString.class, options="Integer,Integer") Closure closure) {
eachWithIndex(new IntArrayIterable(self), closure);
return self;
}
```
This saves work when writing the new variants but is probably slightly less efficient that the current code in this PR.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976651181
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
+ * assert result == 5
+ * </pre>
+ *
+ * @param self an int array
+ * @param closure a Closure to operate on each item
+ * @return the self Object
+ * @since 1.0
+ */
+ public static int[] eachWithIndex(int[] self, @ClosureParams(value=FromString.class, options="int,Integer") Closure closure) {
+ eachWithIndex(new IntArrayIterator(self), closure);
Review Comment:
We could avoid the intermediate object and method calls and just use simple iterative implementation like `T[]` provides.
```java
final Object[] args = new Object[2];
for (int i = 0, n = self.length; i < n; i += 1) {
args[0] = self[i]; args[1] = i;
closure.call(args);
}
```
Yes it will be repeat, but I think the efficiency is more important in this case.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r980582585
##########
src/test/groovy/transform/stc/DefaultGroovyMethodsSTCTest.groovy:
##########
@@ -37,6 +37,20 @@ class DefaultGroovyMethodsSTCTest extends StaticTypeCheckingTestCase {
println it // DGM#println(Object,Object)
}
'''
+
+ assertScript '''
+ int[] nums = [0, 1]
+ nums.each { it -> // ArrayGroovyMethods#each(int[], Closure)
+ println it.toDouble() // DGM#println(Object,Object)
Review Comment:
Though we have many legacy tests which use println, we tend to avoid adding additional such tests when we can since they slow down the build and don't actually get automatically tested (even though the main objective here is for compilation to pass).
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1282188440
Merged, thanks! I might make some minor formatting changes post merge. I am also thinking have the TypeChecked annotation in the groovyTestCase tests in javadoc probably adds noise that doesn't need to be there. I'll ponder whether we should tweak that somehow.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r984915270
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -11693,108 +11299,44 @@ public static boolean asBoolean(Object[] array) {
return array != null && array.length > 0;
}
- /**
- * Coerces a byte array to a boolean value.
- * A byte array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(byte[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a short array to a boolean value.
- * A short array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(short[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces an int array to a boolean value.
- * An int array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(int[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a long array to a boolean value.
- * A long array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(long[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a float array to a boolean value.
- * A float array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(float[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a double array to a boolean value.
- * A double array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(double[] array) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.asBoolean(array)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737545&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737545&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737545&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737545&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737545&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -11693,108 +11299,44 @@ public static boolean asBoolean(Object[] array) {
return array != null && array.length > 0;
}
- /**
- * Coerces a byte array to a boolean value.
- * A byte array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(byte[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a short array to a boolean value.
- * A short array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(short[] array) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.asBoolean(array)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737650&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737650&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737650&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737650&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737650&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(short[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(char[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(boolean[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(double[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(float[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737698&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737698&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737698&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737698&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737698&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the byte array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(byte[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the char array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(char[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the double array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(double[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737703&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737703&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737703&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737703&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737703&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6567,112 +6363,34 @@ public static Object average(Iterator<?> self) {
return result;
}
- /**
- * Calculates the average of the bytes in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as byte[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(byte[] self) {
- long s = 0;
- int count = 0;
- for (byte v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the shorts in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as short[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(short[] self) {
- long s = 0;
- int count = 0;
- for (short v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the ints in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as int[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(int[] self) {
- long s = 0;
- int count = 0;
- for (int v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the longs in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as long[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(long[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.average(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737706&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737706&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737706&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737706&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737706&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6103,88 +6032,39 @@ public static Object sum(Iterator<Object> self) {
return sum(self, null, true);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self) {
- return sum(self, (byte) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as short) == ([1,2,3,4] as short[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self) {
- return sum(self, (short) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert 1+2+3+4 == ([1,2,3,4] as int[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self) {
- return sum(self, 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as long) == ([1,2,3,4] as long[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self) {
- return sum(self, 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as char) == ([1,2,3,4] as char[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static char sum(char[] self) {
- return sum(self, (char) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as float) == ([1,2,3,4] as float[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static float sum(float[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737732&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737732&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737732&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737732&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737732&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6103,88 +6032,39 @@ public static Object sum(Iterator<Object> self) {
return sum(self, null, true);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self) {
- return sum(self, (byte) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as short) == ([1,2,3,4] as short[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737749&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737749&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737749&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737749&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737749&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6567,112 +6363,34 @@ public static Object average(Iterator<?> self) {
return result;
}
- /**
- * Calculates the average of the bytes in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as byte[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(byte[] self) {
- long s = 0;
- int count = 0;
- for (byte v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the shorts in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as short[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(short[] self) {
- long s = 0;
- int count = 0;
- for (short v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the ints in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as int[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(int[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.average(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737766&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737766&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737766&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737766&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737766&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -11693,108 +11299,44 @@ public static boolean asBoolean(Object[] array) {
return array != null && array.length > 0;
}
- /**
- * Coerces a byte array to a boolean value.
- * A byte array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(byte[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a short array to a boolean value.
- * A short array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(short[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces an int array to a boolean value.
- * An int array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(int[] array) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.asBoolean(array)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737773&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737773&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737773&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737773&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737773&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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976644046
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
+ * assert result == 5
+ * </pre>
+ *
+ * @param self an int array
+ * @param closure a Closure to operate on each item
+ * @return the self Object
+ * @since 1.0
+ */
+ public static int[] eachWithIndex(int[] self, @ClosureParams(value=FromString.class, options="int,Integer") Closure closure) {
Review Comment:
I think "int" should be "Integer". The closure params are passed as objects, so there is no optimization like `Consumer` versus `IntConsumer`.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r977124640
##########
src/spec/test/typing/TypeCheckingTest.groovy:
##########
@@ -44,6 +44,23 @@ class TypeCheckingTest extends StaticTypeCheckingTestCase {
'''
}
+ void testTypeCheckedEachWithIndex(){
+ //TODO: tags?
Review Comment:
I added the doco mentioned in previous comment, so if you want to add to the doco, you would update:
https://github.com/apache/groovy/blob/master/src/spec/test/gdk/WorkingWithArraysTest.groovy (probably `testArrayIteration`)
https://github.com/apache/groovy/blob/master/src/spec/doc/_working-with-arrays.adoc (if needed)
This wouldn't cover static compilation unless you added it explicitly, so moving to the aforementioned `DefaultGroovyMethodsSTCTest` might be just as good an option.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r980526924
##########
src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java:
##########
@@ -0,0 +1,85 @@
+package org.codehaus.groovy.runtime;
+
+import groovy.lang.Closure;
+import groovy.transform.stc.ClosureParams;
+import groovy.transform.stc.FirstParam;
+import groovy.transform.stc.FromString;
+
+/**
+ * This class defines new groovy methods which appear on prrimitive arrays inside the Groovy environment.
Review Comment:
typo in 'p**rr**imitive'
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] Shadow-Devil commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
Shadow-Devil commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1277950402
Could someone please approve the workflow?
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1273623794
I'm trying to fight through the sonatype comments. But it is looking ready for review to me.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976634950
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
+ * assert result == 5
+ * </pre>
+ *
+ * @param self an int array
+ * @param closure a Closure to operate on each item
+ * @return the self Object
Review Comment:
Should probably say array instead of Object
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1258399808
:warning: **170 God Classes** were detected by Lift in this project. [Visit the Lift web console](https://lift.sonatype.com/results/github.com/apache/groovy/01GDXARFWERA7TXWZG1ES1XP97?tab=technical-debt&utm_source=github.com&utm_campaign=lift-comment&utm_content=apache\%20groovy) for more details.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976636997
##########
src/spec/test/typing/TypeCheckingTest.groovy:
##########
@@ -44,6 +44,24 @@ class TypeCheckingTest extends StaticTypeCheckingTestCase {
'''
}
+ void testTypeCheckedEachWithIndex(){
+ //TODO: tags?
+ assertScript '''
+ @groovy.transform.TypeChecked
Review Comment:
No need to add this annotation within a `StaticTypeCheckingTestCase`. The test case takes care of this for you and the subclass also applies static compilation.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r984914845
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
- return join(new BooleanArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of byte
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(byte[] self, String separator) {
- return join(new ByteArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of char
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(char[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736988&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736988&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736988&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736988&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736988&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6567,112 +6363,34 @@ public static Object average(Iterator<?> self) {
return result;
}
- /**
- * Calculates the average of the bytes in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as byte[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(byte[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.average(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737125&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737125&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737125&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737125&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737125&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -11693,108 +11299,44 @@ public static boolean asBoolean(Object[] array) {
return array != null && array.length > 0;
}
- /**
- * Coerces a byte array to a boolean value.
- * A byte array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(byte[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a short array to a boolean value.
- * A short array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(short[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces an int array to a boolean value.
- * An int array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(int[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a long array to a boolean value.
- * A long array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(long[] array) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.asBoolean(array)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737188&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737188&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737188&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737188&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737188&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6246,123 +6126,39 @@ private static Object sum(Iterator<?> self, Object initialValue, boolean first)
return result;
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self, byte initialValue) {
- byte s = initialValue;
- for (byte v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as short) == ([1,2,3,4] as short[]).sum(5 as short)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self, short initialValue) {
- short s = initialValue;
- for (short v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert 5+1+2+3+4 == ([1,2,3,4] as int[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self, int initialValue) {
- int s = initialValue;
- for (int v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as long) == ([1,2,3,4] as long[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self, long initialValue) {
- long s = initialValue;
- for (long v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as char) == ([1,2,3,4] as char[]).sum(5 as char)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static char sum(char[] self, char initialValue) {
- char s = initialValue;
- for (char v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as float) == ([1,2,3,4] as float[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static float sum(float[] self, float initialValue) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self, initialValue)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737222&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737222&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737222&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737222&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737222&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6246,123 +6126,39 @@ private static Object sum(Iterator<?> self, Object initialValue, boolean first)
return result;
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self, byte initialValue) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self, initialValue)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737224&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737224&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737224&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737224&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737224&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
- return join(new BooleanArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of byte
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(byte[] self, String separator) {
- return join(new ByteArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of char
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(char[] self, String separator) {
- return join(new CharArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of double
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(double[] self, String separator) {
- return join(new DoubleArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of float
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(float[] self, String separator) {
- return join(new FloatArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of int
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(int[] self, String separator) {
- return join(new IntArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of long
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(long[] self, String separator) {
- return join(new LongArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of short
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(short[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737226&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737226&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737226&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737226&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737226&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(short[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(char[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(boolean[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737213&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737213&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737213&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737213&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737213&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6246,123 +6126,39 @@ private static Object sum(Iterator<?> self, Object initialValue, boolean first)
return result;
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self, byte initialValue) {
- byte s = initialValue;
- for (byte v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as short) == ([1,2,3,4] as short[]).sum(5 as short)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self, short initialValue) {
- short s = initialValue;
- for (short v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert 5+1+2+3+4 == ([1,2,3,4] as int[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self, int initialValue) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self, initialValue)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737234&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737234&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737234&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737234&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737234&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6567,112 +6363,34 @@ public static Object average(Iterator<?> self) {
return result;
}
- /**
- * Calculates the average of the bytes in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as byte[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(byte[] self) {
- long s = 0;
- int count = 0;
- for (byte v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the shorts in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as short[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(short[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.average(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737241&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737241&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737241&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737241&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737241&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(short[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737255&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737255&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737255&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737255&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737255&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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r984914990
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the byte array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(byte[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the char array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(char[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737254&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737254&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737254&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737254&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737254&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
- return join(new BooleanArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of byte
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(byte[] self, String separator) {
- return join(new ByteArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of char
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(char[] self, String separator) {
- return join(new CharArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of double
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(double[] self, String separator) {
- return join(new DoubleArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of float
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(float[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737292&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737292&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737292&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737292&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737292&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the byte array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(byte[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the char array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(char[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the double array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(double[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the float array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(float[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the int array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(int[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737300&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737300&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737300&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737300&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737300&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the byte array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(byte[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737304&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737304&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737304&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737304&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737304&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6103,88 +6032,39 @@ public static Object sum(Iterator<Object> self) {
return sum(self, null, true);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self) {
- return sum(self, (byte) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as short) == ([1,2,3,4] as short[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self) {
- return sum(self, (short) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert 1+2+3+4 == ([1,2,3,4] as int[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self) {
- return sum(self, 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as long) == ([1,2,3,4] as long[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self) {
- return sum(self, 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as char) == ([1,2,3,4] as char[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static char sum(char[] self) {
- return sum(self, (char) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as float) == ([1,2,3,4] as float[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static float sum(float[] self) {
- return sum(self, (float) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as double) == ([1,2,3,4] as double[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static double sum(double[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737319&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737319&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737319&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737319&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737319&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737331&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737331&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737331&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737331&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737331&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6103,88 +6032,39 @@ public static Object sum(Iterator<Object> self) {
return sum(self, null, true);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737355&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737355&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737355&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737355&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737355&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -11693,108 +11299,44 @@ public static boolean asBoolean(Object[] array) {
return array != null && array.length > 0;
}
- /**
- * Coerces a byte array to a boolean value.
- * A byte array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(byte[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a short array to a boolean value.
- * A short array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(short[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces an int array to a boolean value.
- * An int array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(int[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a long array to a boolean value.
- * A long array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(long[] array) {
- return array != null && array.length > 0;
+ return ArrayGroovyMethods.asBoolean(array);
}
- /**
- * Coerces a float array to a boolean value.
- * A float array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(float[] array) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.asBoolean(array)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737357&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737357&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737357&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737357&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737357&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6803,116 +6521,44 @@ public static <T> String join(T[] self, String separator) {
return join(new ArrayIterator<>(self), separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of boolean
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(boolean[] self, String separator) {
- return join(new BooleanArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of byte
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(byte[] self, String separator) {
- return join(new ByteArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of char
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(char[] self, String separator) {
- return join(new CharArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of double
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(double[] self, String separator) {
- return join(new DoubleArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of float
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(float[] self, String separator) {
- return join(new FloatArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of int
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(int[] self, String separator) {
- return join(new IntArrayIterator(self), separator);
+ return ArrayGroovyMethods.join(self, separator);
}
- /**
- * Concatenates the string representation of each
- * items in this array, with the given String as a separator between each
- * item.
- *
- * @param self an array of long
- * @param separator a String separator
- * @return the joined String
- * @since 2.4.1
- */
+ @Deprecated
public static String join(long[] self, String separator) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.join(self, separator)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737370&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737370&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737370&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737370&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737370&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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r976633838
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
Review Comment:
Please ensure that the object expression is of type `int[]` to test the annotated method. This is `List<Integer>` and so it tests another `eachWithIndex` veriant. You can debug `MainJavadocAssertionTest` to see if your addition is hit by any test cases.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r977790800
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -2273,6 +2273,26 @@ public static <T> T[] eachWithIndex(T[] self, @ClosureParams(value=FromString.cl
return self;
}
+ /**
+ * Iterates through an int[],
+ * passing each int and the element's index (a counter starting at
+ * zero) to the given closure.
+ * <pre class="groovyTestCase">
+ * int result = 0
+ * [0, 1, 2].eachWithIndex{ x, index {@code ->} result += x * index }
Review Comment:
To debug a junit test class, you can start gradle like this:
> gradlew :test --tests MainJavadocAssertionTest --no-daemon --debug-jvm
Gradle will start up and build enough to start the requested test(s) and wait for a connection on port 5005. You can connect and debug with your favorite debugger / development environment.
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] eric-milles commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
eric-milles commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1255128099
> If we're adding eachWithIndex it appears we also need each to satisfy STC. Can you add an each(int[]) as well?
The reason I did not pick this ticket up after creating it is there was no reasonable stopping point. If adding `eachWithIndex`, what about `each`, `reverseEach`, `every` and all the other `T[]` extensions. I wonder if there is some way to write just one implementation and have all the primitive versions be generated automatically. @paulk-asert Do you know of such a thing? Or should we consider the possibility of allowing the `T[]` or `Object[]` apply to primitive arrays as well through Groovy "auto-unboxing"?
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r984915130
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6246,123 +6126,39 @@ private static Object sum(Iterator<?> self, Object initialValue, boolean first)
return result;
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self, byte initialValue) {
- byte s = initialValue;
- for (byte v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as short) == ([1,2,3,4] as short[]).sum(5 as short)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self, short initialValue) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self, initialValue)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737426&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737426&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737426&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737426&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737426&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6567,112 +6363,34 @@ public static Object average(Iterator<?> self) {
return result;
}
- /**
- * Calculates the average of the bytes in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as byte[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(byte[] self) {
- long s = 0;
- int count = 0;
- for (byte v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the shorts in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as short[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(short[] self) {
- long s = 0;
- int count = 0;
- for (short v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the ints in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as int[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(int[] self) {
- long s = 0;
- int count = 0;
- for (int v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the longs in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as long[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(long[] self) {
- long s = 0;
- int count = 0;
- for (long v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the floats in the array.
- * <pre class="groovyTestCase">assert 5.0d == ([2,4,6,8] as float[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static double average(float[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.average(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737429&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737429&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737429&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737429&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737429&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(short[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(char[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737447&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737447&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737447&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737447&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737447&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6567,112 +6363,34 @@ public static Object average(Iterator<?> self) {
return result;
}
- /**
- * Calculates the average of the bytes in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as byte[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(byte[] self) {
- long s = 0;
- int count = 0;
- for (byte v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the shorts in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as short[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(short[] self) {
- long s = 0;
- int count = 0;
- for (short v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the ints in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as int[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(int[] self) {
- long s = 0;
- int count = 0;
- for (int v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the longs in the array.
- * <pre class="groovyTestCase">assert 5.0G == ([2,4,6,8] as long[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static BigDecimal average(long[] self) {
- long s = 0;
- int count = 0;
- for (long v : self) {
- s += v;
- count++;
- }
- return BigDecimal.valueOf(s).divide(BigDecimal.valueOf(count));
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the floats in the array.
- * <pre class="groovyTestCase">assert 5.0d == ([2,4,6,8] as float[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static double average(float[] self) {
- double s = 0.0d;
- int count = 0;
- for (float v : self) {
- s += v;
- count++;
- }
- return s/count;
+ return ArrayGroovyMethods.average(self);
}
- /**
- * Calculates the average of the doubles in the array.
- * <pre class="groovyTestCase">assert 5.0d == ([2,4,6,8] as double[]).average()</pre>
- *
- * @param self The array of values to calculate the average of
- * @return The average of the items
- * @since 3.0.0
- */
+ @Deprecated
public static double average(double[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.average(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737452&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737452&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737452&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737452&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737452&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6103,88 +6032,39 @@ public static Object sum(Iterator<Object> self) {
return sum(self, null, true);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self) {
- return sum(self, (byte) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as short) == ([1,2,3,4] as short[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self) {
- return sum(self, (short) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert 1+2+3+4 == ([1,2,3,4] as int[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737478&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737478&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737478&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737478&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737478&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737485&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737485&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737485&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737485&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737485&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(short[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(char[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(boolean[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(double[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(float[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(byte[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737509&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737509&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737509&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737509&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737509&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the byte array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(byte[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the char array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(char[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the double array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(double[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the float array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(float[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737543&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737543&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737543&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737543&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737543&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the byte array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(byte[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the char array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(char[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the double array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(double[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the float array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(float[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the int array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(int[] self) {
- return new IntRange(false, 0, self.length);
+ return ArrayGroovyMethods.getIndices(self);
}
- /**
- * Returns indices of the long array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(long[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340737538&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340737538&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737538&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340737538&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340737538&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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] sonatype-lift[bot] commented on a diff in pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #1785:
URL: https://github.com/apache/groovy/pull/1785#discussion_r984914687
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(long[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(short[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(char[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(boolean[] self, Object value) {
- return count(InvokerHelper.asIterator(self), value);
+ return ArrayGroovyMethods.count(self, value);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(double[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736745&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736745&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736745&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736745&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736745&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6246,123 +6126,39 @@ private static Object sum(Iterator<?> self, Object initialValue, boolean first)
return result;
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self, byte initialValue) {
- byte s = initialValue;
- for (byte v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as short) == ([1,2,3,4] as short[]).sum(5 as short)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self, short initialValue) {
- short s = initialValue;
- for (short v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert 5+1+2+3+4 == ([1,2,3,4] as int[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self, int initialValue) {
- int s = initialValue;
- for (int v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as long) == ([1,2,3,4] as long[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self, long initialValue) {
- long s = initialValue;
- for (long v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as char) == ([1,2,3,4] as char[]).sum(5 as char)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static char sum(char[] self, char initialValue) {
- char s = initialValue;
- for (char v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as float) == ([1,2,3,4] as float[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static float sum(float[] self, float initialValue) {
- float s = initialValue;
- for (float v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as double) == ([1,2,3,4] as double[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static double sum(double[] self, double initialValue) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self, initialValue)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736771&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736771&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736771&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736771&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736771&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6246,123 +6126,39 @@ private static Object sum(Iterator<?> self, Object initialValue, boolean first)
return result;
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self, byte initialValue) {
- byte s = initialValue;
- for (byte v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as short) == ([1,2,3,4] as short[]).sum(5 as short)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self, short initialValue) {
- short s = initialValue;
- for (short v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert 5+1+2+3+4 == ([1,2,3,4] as int[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self, int initialValue) {
- int s = initialValue;
- for (int v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as long) == ([1,2,3,4] as long[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self, long initialValue) {
- long s = initialValue;
- for (long v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as char) == ([1,2,3,4] as char[]).sum(5 as char)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static char sum(char[] self, char initialValue) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self, initialValue)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736800&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736800&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736800&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736800&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736800&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6103,88 +6032,39 @@ public static Object sum(Iterator<Object> self) {
return sum(self, null, true);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self) {
- return sum(self, (byte) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as short) == ([1,2,3,4] as short[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self) {
- return sum(self, (short) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert 1+2+3+4 == ([1,2,3,4] as int[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self) {
- return sum(self, 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as long) == ([1,2,3,4] as long[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self) {
- return sum(self, 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as char) == ([1,2,3,4] as char[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static char sum(char[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736910&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736910&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736910&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736910&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736910&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -11693,108 +11299,44 @@ public static boolean asBoolean(Object[] array) {
return array != null && array.length > 0;
}
- /**
- * Coerces a byte array to a boolean value.
- * A byte array is false if the array is of length 0,
- * and true otherwise.
- *
- * @param array an array
- * @return the array's boolean value
- * @since 1.7.4
- */
+ @Deprecated
public static boolean asBoolean(byte[] array) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.asBoolean(array)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736959&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736959&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736959&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736959&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736959&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -3178,116 +3179,44 @@ public static <T> Number count(T[] self, @ClosureParams(FirstParam.Component.cla
return count(Arrays.asList(self), closure);
}
- /**
- * Counts the number of occurrences of the given value inside this array.
- * Comparison is done using Groovy's == operator (using
- * <code>compareTo(value) == 0</code> or <code>equals(value)</code> ).
- *
- * @param self the array within which we count the number of occurrences
- * @param value the value being searched for
- * @return the number of occurrences
- * @since 1.6.4
- */
+ @Deprecated
public static Number count(int[] self, Object value) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.count(self, value)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736963&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736963&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736963&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736963&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736963&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6246,123 +6126,39 @@ private static Object sum(Iterator<?> self, Object initialValue, boolean first)
return result;
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum(5 as byte)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self, byte initialValue) {
- byte s = initialValue;
- for (byte v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as short) == ([1,2,3,4] as short[]).sum(5 as short)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self, short initialValue) {
- short s = initialValue;
- for (short v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert 5+1+2+3+4 == ([1,2,3,4] as int[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self, int initialValue) {
- int s = initialValue;
- for (int v : self) {
- s += v;
- }
- return s;
+ return ArrayGroovyMethods.sum(self, initialValue);
}
- /**
- * Sums the items in an array, adding the result to some initial value.
- * <pre class="groovyTestCase">assert (5+1+2+3+4 as long) == ([1,2,3,4] as long[]).sum(5)</pre>
- *
- * @param self an array of values to sum
- * @param initialValue the items in the array will be summed to this initial value
- * @return The sum of all of the items.
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self, long initialValue) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self, initialValue)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736958&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736958&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736958&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736958&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736958&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -7549,84 +7195,44 @@ public static <T> IntRange getIndices(T[] self) {
return new IntRange(false, 0, self.length);
}
- /**
- * Returns indices of the boolean array.
- *
- * @see #getIndices(Object[])
- * @since 3.0.8
- */
+ @Deprecated
public static IntRange getIndices(boolean[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.getIndices(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736962&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736962&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736962&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736962&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736962&lift_comment_rating=5) ]
##########
src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java:
##########
@@ -6103,88 +6032,39 @@ public static Object sum(Iterator<Object> self) {
return sum(self, null, true);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as byte) == ([1,2,3,4] as byte[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static byte sum(byte[] self) {
- return sum(self, (byte) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as short) == ([1,2,3,4] as short[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static short sum(short[] self) {
- return sum(self, (short) 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert 1+2+3+4 == ([1,2,3,4] as int[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static int sum(int[] self) {
- return sum(self, 0);
+ return ArrayGroovyMethods.sum(self);
}
- /**
- * Sums the items in an array.
- * <pre class="groovyTestCase">assert (1+2+3+4 as long) == ([1,2,3,4] as long[]).sum()</pre>
- *
- * @param self The array of values to add together
- * @return The sum of all of the items
- * @since 2.4.2
- */
+ @Deprecated
public static long sum(long[] self) {
Review Comment:
*[InlineMeSuggester](https://errorprone.info/bugpattern/InlineMeSuggester):* This deprecated API looks inlineable. If you'd like the body of the API to be inlined to its callers, please annotate it with @InlineMe.
---
```suggestion
@InlineMe(replacement = "ArrayGroovyMethods.sum(self)", imports = "org.codehaus.groovy.runtime.ArrayGroovyMethods")
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with ***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified `file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=340736972&lift_comment_rating=1) ] - [ [đ Won't fix](https://www.sonatype.com/lift-comment-rating?comment=340736972&lift_comment_rating=2) ] - [ [đ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736972&lift_comment_rating=3) ] - [ [đ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=340736972&lift_comment_rating=4) ] - [ [đ Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=340736972&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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [groovy] paulk-asert commented on pull request #1785: GROOVY-10682: Provide eachWithIndex for primitive arrays
Posted by GitBox <gi...@apache.org>.
paulk-asert commented on PR #1785:
URL: https://github.com/apache/groovy/pull/1785#issuecomment-1282172609
LGTM
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org