Full language coverage.

      The remaining tasks should be driven by throw new UnsupportedOperationException in CpsTransformer.

      • synchronized statements (maybe warn and ignore?)
      • Method pointer expression
      • List spread expression x=[2,3]; y=[1,*x,4]; assert y=[1,2,3,4]
      • Map spread expression
      • Spread method call: x = [1,2,3]; assert x*.toString() = ["1","2","3"]
      • Safe method call: x=null; assert x?.foo()==null

      See also comment in localMethodCallWithinLotsOfBranches.groovy.

      Must also ensure that any exception in this area is properly reported as an error in the log, rather than simply killing the VM thread.

          [JENKINS-25979] Finish Groovy CPS coverage

          Phil McArdle added a comment -

          Forgive me if part of this task is also adding the UnsupportedOperationException for these operators - only, the wording suggests the exception is already present, otherwise, I've stumbled across this because I tried to use a spread method call and received the following exception instead:

          hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.util.Collections$UnmodifiableRandomAccessList.getShortDescription() is applicable for argument types: () values: []
          
          def rawCauses = currentBuild.rawBuild.getCauses()
          def causes = rawCauses*.getShortDescription()
          

          I then tried to use collect, and of course found JENKINS-26481 (I switched to a for loop)

          In both cases, it would be a huge advantage to someone learning Pipeline and Groovy if Jenkins would reject these with clear exceptions.

          Phil McArdle added a comment - Forgive me if part of this task is also adding the UnsupportedOperationException for these operators - only, the wording suggests the exception is already present, otherwise, I've stumbled across this because I tried to use a spread method call and received the following exception instead: hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.util.Collections$UnmodifiableRandomAccessList.getShortDescription() is applicable for argument types: () values: [] def rawCauses = currentBuild.rawBuild.getCauses() def causes = rawCauses*.getShortDescription() I then tried to use collect, and of course found JENKINS-26481 (I switched to a for loop) In both cases, it would be a huge advantage to someone learning Pipeline and Groovy if Jenkins would reject these with clear exceptions.

          Jesse Glick added a comment -

          The spread operator is covered by JENKINS-33051. Last I checked it does throw an UnsupportedOperationException, but maybe not in all cases.

          Jesse Glick added a comment - The spread operator is covered by JENKINS-33051 . Last I checked it does throw an UnsupportedOperationException , but maybe not in all cases.

            kohsuke Kohsuke Kawaguchi
            jglick Jesse Glick
            Votes:
            9 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: