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

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 27fdf96842ea [SPARK-47697][INFRA] Add Scala style check for invalid 
MDC usage
27fdf96842ea is described below

commit 27fdf96842ea5a98ea5835bbf78b33b26db1fd3b
Author: Gengliang Wang <gengli...@apache.org>
AuthorDate: Tue Apr 2 15:45:23 2024 -0700

    [SPARK-47697][INFRA] Add Scala style check for invalid MDC usage
    
    ### What changes were proposed in this pull request?
    
    Add Scala style check for invalid MDC usage to avoid invalid MDC usage 
`s"Task ${MDC(TASK_ID, taskId)} failed"`, which should be `log"Task 
${MDC(TASK_ID, taskId)} failed"`.
    
    ### Why are the changes needed?
    
    This makes development and PR review of the structured logging migration 
easier.
    
    ### Does this PR introduce _any_ user-facing change?
    
    NO
    
    ### How was this patch tested?
    
    Manual test, verified it will throw errors on invalid MDC usage.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #45823 from gengliangwang/style.
    
    Authored-by: Gengliang Wang <gengli...@apache.org>
    Signed-off-by: Dongjoon Hyun <dh...@apple.com>
---
 scalastyle-config.xml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scalastyle-config.xml b/scalastyle-config.xml
index 50bd5a33ccb2..cd5a576c086f 100644
--- a/scalastyle-config.xml
+++ b/scalastyle-config.xml
@@ -150,6 +150,11 @@ This file is divided into 3 sections:
       // scalastyle:on println]]></customMessage>
   </check>
 
+  <check customId="invalidMDC" level="error" 
class="org.scalastyle.file.RegexChecker" enabled="true">
+    <parameters><parameter name="regex">s".*\$\{MDC\(</parameter></parameters>
+    <customMessage><![CDATA[MDC should be used in string interpolation 
log"..." instead of s"..."]]></customMessage>
+  </check>
+
   <check customId="hadoopconfiguration" level="error" 
class="org.scalastyle.file.RegexChecker" enabled="true">
     <parameters><parameter 
name="regex">spark(.sqlContext)?.sparkContext.hadoopConfiguration</parameter></parameters>
     <customMessage><![CDATA[


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to