You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/03/22 00:20:30 UTC

[groovy] branch GROOVY_3_0_X updated (b10fe52 -> e84359e)

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a change to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from b10fe52  Ignore the tests only existing in the groovy-parser project
     new ee418d5  Support inspecting the code quality and security with SonarQube
     new 4895cf6  Add a badge of sonarcloud
     new 70818f1  Get complete git blame information
     new 821c2f3  Avoid unnecessary boxing and unbox of primitive values.
     new e84359e  ConversionHandler: Remove unnecessary null check for value of final field which is always initialized.

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .travis.yml                                                      | 9 +++++++--
 README.adoc                                                      | 3 +++
 build.gradle                                                     | 1 +
 gradle/quality.gradle                                            | 8 ++++++++
 src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java | 2 +-
 .../java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java   | 2 +-
 .../groovy/runtime/typehandling/DefaultTypeTransformation.java   | 8 ++++----
 .../org/codehaus/groovy/transform/FieldASTTransformation.java    | 2 +-
 .../org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy | 2 +-
 9 files changed, 27 insertions(+), 10 deletions(-)


[groovy] 04/05: Avoid unnecessary boxing and unbox of primitive values.

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 821c2f36881035c2c998831ed88ac65f8531e3c6
Author: Pascal Schumacher <pa...@gmx.net>
AuthorDate: Sat Mar 21 13:56:37 2020 +0100

    Avoid unnecessary boxing and unbox of primitive values.
    
    This improves readability because it makes it clear that the value can never be null.
    
    (cherry picked from commit 05e9b2dc1f1b39d995d6f60053d37d35c0812164)
---
 .../java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java    | 2 +-
 .../groovy/runtime/typehandling/DefaultTypeTransformation.java    | 8 ++++----
 .../org/codehaus/groovy/transform/FieldASTTransformation.java     | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index c06d628..e548382 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -13069,7 +13069,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
      */
     public static <T> List<List<T>> chop(Iterator<T> self, int... chopSizes) {
         List<List<T>> result = new ArrayList<List<T>>();
-        for (Integer nextSize : chopSizes) {
+        for (int nextSize : chopSizes) {
             int size = nextSize;
             List<T> next = new ArrayList<T>();
             while (size-- != 0 && self.hasNext()) {
diff --git a/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java b/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
index ed83ddc..f53a551 100644
--- a/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
+++ b/src/main/java/org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.java
@@ -299,12 +299,12 @@ public class DefaultTypeTransformation {
                 return n.floatValue();
             }
             if (type == Double.class) {
-                Double answer = n.doubleValue();
+                double answer = n.doubleValue();
                 //throw a runtime exception if conversion would be out-of-range for the type.
                 if (!(n instanceof Double) && (answer == Double.NEGATIVE_INFINITY
                         || answer == Double.POSITIVE_INFINITY)) {
                     throw new GroovyRuntimeException("Automatic coercion of " + n.getClass().getName()
-                            + " value " + n + " to double failed.  Value is out of range.");
+                            + " value " + n + " to double failed. Value is out of range.");
                 }
                 return answer;
             }
@@ -345,12 +345,12 @@ public class DefaultTypeTransformation {
         } else if (type == float.class) {
             return floatUnbox(object);
         } else if (type == double.class) {
-            Double answer = doubleUnbox(object);
+            double answer = doubleUnbox(object);
             //throw a runtime exception if conversion would be out-of-range for the type.
             if (!(object instanceof Double) && (answer == Double.NEGATIVE_INFINITY
                     || answer == Double.POSITIVE_INFINITY)) {
                 throw new GroovyRuntimeException("Automatic coercion of " + object.getClass().getName()
-                        + " value " + object + " to double failed.  Value is out of range.");
+                        + " value " + object + " to double failed. Value is out of range.");
             }
             return answer;
         } //nothing else possible
diff --git a/src/main/java/org/codehaus/groovy/transform/FieldASTTransformation.java b/src/main/java/org/codehaus/groovy/transform/FieldASTTransformation.java
index 78f1ff1..1c08118 100644
--- a/src/main/java/org/codehaus/groovy/transform/FieldASTTransformation.java
+++ b/src/main/java/org/codehaus/groovy/transform/FieldASTTransformation.java
@@ -273,7 +273,7 @@ public class FieldASTTransformation extends ClassCodeExpressionTransformer imple
 
     @Override
     public void visitMethod(MethodNode node) {
-        Boolean oldInsideScriptBody = insideScriptBody;
+        boolean oldInsideScriptBody = insideScriptBody;
         if (node.isScriptBody()) insideScriptBody = true;
         super.visitMethod(node);
         insideScriptBody = oldInsideScriptBody;


[groovy] 02/05: Add a badge of sonarcloud

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 4895cf66676fa053ea448e56f4a35a9fe9544ba3
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Mar 22 07:13:26 2020 +0800

    Add a badge of sonarcloud
    
    (cherry picked from commit b531f4463c7d1b279fd592d5005eb66bbd746e2e)
---
 README.adoc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/README.adoc b/README.adoc
index 1a033b6..ed4b564 100644
--- a/README.adoc
+++ b/README.adoc
@@ -24,10 +24,12 @@ The Groovy development team
 :revdate: 24-02-2014
 :build-icon: http://ci.groovy-lang.org:8111/app/rest/builds/buildType:(id:Groovy_Jdk7Build)/statusIcon
 :travis-build-icon: https://travis-ci.org/apache/groovy.svg?branch=master
+:sonarcloud-icon: https://sonarcloud.io/api/project_badges/measure?project=apache_groovy&metric=alert_status
 :noheader:
 :groovy-www: https://groovy-lang.org/
 :groovy-ci: http://ci.groovy-lang.org?guest=1
 :travis-ci: https://travis-ci.org/apache/groovy
+:sonarcloud: https://sonarcloud.io/dashboard?id=apache_groovy
 :jdk: https://www.oracle.com/technetwork/java/javase/downloads
 :bintray-latest-version-image: https://api.bintray.com/packages/groovy/maven/groovy/images/download.png
 :bintray-latest-version-link: https://bintray.com/groovy/maven/groovy/_latestVersion
@@ -51,6 +53,7 @@ image:{jdk-icon}[jdk, link={jdk}]
 image:{apache-license-icon}[Apache License 2, link={apache-license-link}]
 // image:{build-icon}[teamcity build status, link={groovy-ci}]
 image:{travis-build-icon}[travis build status, link={travis-ci}]
+image:{sonarcloud-icon}[quality gate status, link={sonarcloud}]
 image:{bintray-download-icon}[bintray download, link={bintray-latest-version-link}]
 image:{apache-groovy-twitter-icon}[follow on Twitter, link={apache-groovy-twitter-link}]
 


[groovy] 01/05: Support inspecting the code quality and security with SonarQube

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit ee418d503d43d0be2af1ae09fc577f3f3de2d8e4
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Mar 22 07:05:26 2020 +0800

    Support inspecting the code quality and security with SonarQube
    
    (cherry picked from commit cdf6f7d2b7ba88875f702267287225aec7f60152)
---
 .travis.yml                                                       | 5 ++++-
 build.gradle                                                      | 1 +
 gradle/quality.gradle                                             | 8 ++++++++
 .../org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy  | 2 +-
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a75e5ce..46a259e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -53,12 +53,15 @@ matrix:
     - env: BC='indy'
       jdk: oraclejdk8
 
+    - env: BC='sonar'
+      jdk: openjdk11
+
 before_script:
   - unset _JAVA_OPTIONS
 
 script:
   - ./gradlew -version
-  - if [ "$BC" == "legacy" ]; then travis_wait 60 ./gradlew test; else travis_wait 60 ./gradlew testWithIndy; fi
+  - if [ "$BC" == "legacy" ]; then travis_wait 60 ./gradlew test; elif [ "$BC" == "sonar" ]; then travis_wait 60 ./gradlew sonarqube -Dsonar.login=$SONAR_LOGIN -Pcoverage=true; else travis_wait 60 ./gradlew testWithIndy; fi
 
 # As recommended in:
 # https://docs.travis-ci.com/user/languages/java/#Caching
diff --git a/build.gradle b/build.gradle
index 5dfb1f3..b209351 100644
--- a/build.gradle
+++ b/build.gradle
@@ -49,6 +49,7 @@ plugins {
     id 'com.github.spotbugs' version '4.0.2'
     id 'com.github.ben-manes.versions' version '0.28.0'
     id 'com.github.blindpirate.osgi' version '0.0.3'
+    id 'org.sonarqube' version '2.8'
 }
 
 buildScanRecipes {
diff --git a/gradle/quality.gradle b/gradle/quality.gradle
index 48eb00d..9912f6f 100644
--- a/gradle/quality.gradle
+++ b/gradle/quality.gradle
@@ -201,3 +201,11 @@ rat {
 }
 
 apply from: 'gradle/jacoco/jacoco.gradle'
+
+sonarqube {
+    properties {
+        property "sonar.projectKey", "apache_groovy"
+        property "sonar.organization", "apache"
+        property "sonar.host.url", "https://sonarcloud.io"
+    }
+}
diff --git a/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy b/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy
index 04affc0..b3c477d 100644
--- a/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/GeneratedAnnotationTest.groovy
@@ -57,7 +57,7 @@ class GeneratedAnnotationTest extends GroovyShellTestCase {
 
         GroovyObject.declaredMethods.findAll{ !isCoverageInstrumentationMethod(it) }.each { m ->
             def method = person.class.declaredMethods.find { it.name == m.name }
-            if (method) {
+            if (method && !method.name.contains('jacoco')) {
                 assert method.annotations*.annotationType().name.contains('groovy.transform.Generated')
             }
         }


[groovy] 05/05: ConversionHandler: Remove unnecessary null check for value of final field which is always initialized.

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit e84359e080dc52f0a199f07320448e24faf629a0
Author: Pascal Schumacher <pa...@gmx.net>
AuthorDate: Sat Mar 21 14:12:50 2020 +0100

    ConversionHandler: Remove unnecessary null check for value of final field which is always initialized.
    
    (cherry picked from commit 1b8c786787fa2289a6f32656fd03e1eababcee2d)
---
 src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java b/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java
index 77a92f6..04870c9 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ConversionHandler.java
@@ -92,7 +92,7 @@ public abstract class ConversionHandler implements InvocationHandler, Serializab
      * @see InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
      */
     public Object invoke(final Object proxy, Method method, Object[] args) throws Throwable {
-        if (handleCache != null && isDefaultMethod(method) && !defaultOverridden(method)) {
+        if (isDefaultMethod(method) && !defaultOverridden(method)) {
             final VMPlugin plugin = VMPluginFactory.getPlugin();
             Object handle = handleCache.computeIfAbsent(method, m -> plugin.getInvokeSpecialHandle(m, proxy));
             return plugin.invokeHandle(handle, args);


[groovy] 03/05: Get complete git blame information

Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 70818f1732140712fd4fe6632e678928d14b022d
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Mar 22 07:37:46 2020 +0800

    Get complete git blame information
    
    (cherry picked from commit 971af1d9e103c3721952552f656958349367516a)
---
 .travis.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 46a259e..174d4cc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,7 +19,9 @@ language: groovy
 # https://docs.travis-ci.com/user/reference/overview/
 sudo: required
 dist: trusty
-install: true
+
+install:
+  - git fetch --unshallow
 
 matrix:
   include: