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

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

sonarqubecloud[bot] commented on PR #2536:
URL: https://github.com/apache/groovy/pull/2536#issuecomment-4466724613

   ## [![Quality Gate 
Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png
 'Quality Gate 
Passed')](https://sonarcloud.io/dashboard?id=apache_groovy&pullRequest=2536) 
**Quality Gate passed**  
   Issues  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 New 
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2536&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png
 '') [0 Accepted 
issues](https://sonarcloud.io/project/issues?id=apache_groovy&pullRequest=2536&issueStatuses=ACCEPTED)
   
   Measures  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_groovy&pullRequest=2536&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_groovy&pullRequest=2536&metric=new_coverage&view=list)
  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png
 '') [0.0% Duplication on New 
Code](https://sonarcloud.io/component_measures?id=apache_groovy&pullRequest=2536&metric=new_duplicated_lines_density&view=list)
  
     
   <!

> New optional type checking extension: CombinerChecker to verify associative 
> combiners in injectParallel/sumParallel/Stream.reduce
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12013
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12013
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>
> h3. Summary
> Adds two incubating annotations and an opt-in type-checking extension that 
> verify, at compile time, that the combiner passed to a parallel or stream 
> reduction is associative (and, for seeded forms, that the seed is an identity 
> element) — the contract such reductions silently require but cannot otherwise 
> enforce.
> h3. Annotations ({{groovy.transform}})
> * {{@Associative}} — declares a two-argument combiner is associative:
>   {{combine(a, combine(b, c)) == combine(combine(a, b), c)}}.
> * {{@Reducer}} — associative *and* has an identity element, named via the
>   {{zero()}} member (e.g. {{@Reducer(zero = '0')}}).
> h3. CombinerChecker ({{groovy.typecheckers}})
> A type-checking extension enabled with
> {{@TypeChecked(extensions='groovy.typecheckers.CombinerChecker')}}.
> It inspects the combiner of:
> * Groovy's parallel collection reductions {{injectParallel}} and
>   {{sumParallel}};
> * the JDK stream reductions {{Stream}}, {{IntStream}}, {{LongStream}} and
>   {{DoubleStream}} {{reduce}} (all overloads).
> The combiner is accepted when it is:
> * a method reference to an {{@Associative}}/{{@Reducer}} method; or
> * a method reference to, or a thin delegating closure over, a {{Monoid}}
>   or {{Semigroup}} from any library (matched by simple type name —
>   Functional Java, Palatable Lambda, Purefun, etc. — configurable via the
>   {{monoids}}/{{semigroups}} options, no dependency added).
> It reports a compile-time error when:
> * an inline closure applies a non-associative operator ({{-}}, {{/}}, {{%}},
>   {{**}}) directly to its two arguments;
> * the seed of a seeded reduction contradicts a {{@Reducer}}'s declared
>   identity;
> * a {{Semigroup}} (which has no identity) is used with a seeded reduction
>   that requires one.
> Two modes: the default (lenient) flags only high-confidence problems; *strict*
> ({{CombinerChecker(mode: 'strict')}}) additionally requires the combiner to
> carry a declared, verifiable contract.
> h3. Notes and non-goals
> * The checker runs only under {{@TypeChecked}}/{{@CompileStatic}} and treats
>   the annotations/carrier types as asserted contracts (not proofs);
>   sequential {{inject}} is deliberately never flagged.
> * The inline-closure check is syntactic and assumes operators carry their
>   conventional meaning. Resolving overloaded operators is a non-goal: in
>   particular, overloading a normally-associative operator (e.g. {{+}}, {{*}})
>   to be non-associative is poor style and is not detected by design. The
>   declaration paths ({{@Associative}}/{{@Reducer}}, Monoid/Semigroup) are the
>   reliable, overloading-immune way to assert the contract.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to