[ 
https://issues.apache.org/jira/browse/GROOVY-12791?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18147995#comment-18147995
 ] 

ASF GitHub Bot commented on GROOVY-12791:
-----------------------------------------

codecov-commenter commented on PR #3314:
URL: https://github.com/apache/groovy/pull/3314#issuecomment-7033068395

   ## 
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3314?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 Report
   :x: Patch coverage is `81.81818%` with `10 lines` in your changes missing 
coverage. Please review.
   :white_check_mark: Project coverage is 74.5985%. Comparing base 
([`077ff21`](https://app.codecov.io/gh/apache/groovy/commit/077ff21217c82a6e26c5d06962947449250118ee?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
 to head 
([`ef025ca`](https://app.codecov.io/gh/apache/groovy/commit/ef025ca2fbad9a2b3883b343ce6470dc16619c13?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3314?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Patch % | Lines |
   |---|---|---|
   | 
[.../main/java/org/codehaus/groovy/ast/ModuleNode.java](https://app.codecov.io/gh/apache/groovy/pull/3314?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FModuleNode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9Nb2R1bGVOb2RlLmphdmE=)
 | 81.2500% | [5 Missing and 4 partials :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3314?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   | 
[...us/groovy/transform/NoScriptASTTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/3314?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FNoScriptASTTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9Ob1NjcmlwdEFTVFRyYW5zZm9ybWF0aW9uLmphdmE=)
 | 85.7143% | [0 Missing and 1 partial :warning: 
](https://app.codecov.io/gh/apache/groovy/pull/3314?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree 
graph](https://app.codecov.io/gh/apache/groovy/pull/3314/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/3314?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #3314        +/-   ##
   ==================================================
   + Coverage     74.5922%   74.5985%   +0.0063%     
   - Complexity      45392      45421        +29     
   ==================================================
     Files            1707       1708         +1     
     Lines          153244     153298        +54     
     Branches        29467      29485        +18     
   ==================================================
   + Hits           114308     114358        +50     
   - Misses          28422      28426         +4     
     Partials        10514      10514                
   ```
   
   | [Files with missing 
lines](https://app.codecov.io/gh/apache/groovy/pull/3314?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
 | Coverage Ξ” | |
   |---|---|---|
   | 
[...us/groovy/transform/NoScriptASTTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/3314?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FNoScriptASTTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9Ob1NjcmlwdEFTVFRyYW5zZm9ybWF0aW9uLmphdmE=)
 | `85.7143% <85.7143%> (ΓΈ)` | |
   | 
[.../main/java/org/codehaus/groovy/ast/ModuleNode.java](https://app.codecov.io/gh/apache/groovy/pull/3314?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FModuleNode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9Nb2R1bGVOb2RlLmphdmE=)
 | `87.8378% <81.2500%> (-1.0166%)` | :arrow_down: |
   
   ... and [15 files with indirect coverage 
changes](https://app.codecov.io/gh/apache/groovy/pull/3314/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test 
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, 
report on failures, and find test suite problems.
   - :package: [JS Bundle 
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save 
yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>




> @NoScript: compile a script file containing only methods and declarations as 
> a plain class
> ------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12791
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12791
>             Project: Groovy
>          Issue Type: New Feature
>          Components: Compiler
>            Reporter: Paul King
>            Priority: Major
>
> A script file containing only method definitions is compiled to a 
> {{groovy.lang.Script}} subclass, with a {{Binding}} constructor, an empty 
> {{run()}} and a {{main}}:
> {code:groovy}
> // Foo.groovy
> def foo() { println new Date() }
> {code}
> {noformat}
> public class Foo extends groovy.lang.Script {
>   public Foo();
>   public Foo(groovy.lang.Binding);
>   public static void main(java.lang.String...);
>   public java.lang.Object run();
>   public java.lang.Object foo();
> }
> {noformat}
> Writing a {{main}} method instead produces a plain class (GROOVY-11118), but 
> it is package-private and adds a {{main}} method. That does not suit 
> frameworks that expect a class with exactly one method, such as some 
> dependency injection frameworks.
> Proposal: a {{@groovy.transform.NoScript}} annotation (incubating, source 
> retention) with the same targets as {{@BaseScript}}: package, import, 
> top-level declaration and type. It compiles the file as if it were:
> {code:groovy}
> class Foo {
>     def foo() { println new Date() }
> }
> {code}
> * The class is public, extends {{Object}}, and has no {{run()}}, no generated 
> {{main}} and no {{Binding}} constructor.
> * Top-level declarations become fields.
> * When every method is static and there are no declarations, the class gets a 
> private no-arg constructor.
> * Other annotations next to {{@NoScript}} on the package declaration or an 
> import are moved to the class, so {{@CompileStatic}} and {{@POJO}} can apply 
> to the whole class:
> {code:groovy}
> import groovy.transform.CompileStatic
> import groovy.transform.stc.POJO
> @NoScript @CompileStatic @POJO
> import groovy.transform.NoScript
> def foo() { println new Date() }
> {code}
> * A {{@NoScript}} file with statements other than declarations is a compile 
> error. So is a {{@NoScript}} that has no effect, for example in a file 
> containing only classes.
> Since {{ModuleNode.createStatementsClass()}} runs before any transform, the 
> annotation is recognised by name there, as {{@Override}} already is for 
> {{main}}.
> Open questions:
> * Whether the type target should stay. It only matches {{@BaseScript}} and is 
> reported as an error on a class.
> * Annotations on a {{@NoScript}} top-level declaration are not copied to the 
> field, the same as on the instance-main path.
> * A {{@NoScript}} file without {{main}} cannot be run with {{groovy 
> Foo.groovy}} or {{GroovyShell.evaluate}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to