File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
main/java/org/sonar/python/checks Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ public class CommentedCodeCheck extends PythonSubscriptionCheck {
49
49
private static final Pattern IS_EMPTY_PATTERN = Pattern .compile ("\\ s*" );
50
50
51
51
private static final String DEFAULT_EXCEPTION_PATTERN = "(fmt|py\\ w+):.*" ;
52
+ private static final Pattern DATABRICKS_MAGIC_COMMAND_PATTERN = Pattern .compile ("^\\ h*(MAGIC|COMMAND).*" );
52
53
private static final PythonParser parser = PythonParser .create ();
53
54
54
55
private Pattern exceptionPattern ;
@@ -125,7 +126,8 @@ private String getTextForParsing(List<Trivia> triviaGroup) {
125
126
}
126
127
127
128
private boolean isException (String text ) {
128
- return exceptionPattern .matcher (text ).matches ();
129
+ boolean isDatabricksMagicCommand = DATABRICKS_MAGIC_COMMAND_PATTERN .matcher (text ).matches ();
130
+ return exceptionPattern .matcher (text ).matches () || isDatabricksMagicCommand ;
129
131
}
130
132
131
133
private static boolean isOneWord (String text ) {
Original file line number Diff line number Diff line change @@ -138,3 +138,12 @@ def testFunction():
138
138
139
139
# abcfmt: off
140
140
# abcpylint: disable=line-too-long
141
+
142
+
143
+ # Databricks notebooks
144
+ # COMMAND ----------
145
+
146
+ # MAGIC %md
147
+ # MAGIC ## Alter tables
148
+
149
+ # COMMAND ----------
You can’t perform that action at this time.
0 commit comments