tuxji commented on code in PR #947:
URL: https://github.com/apache/daffodil/pull/947#discussion_r1102067439


##########
.scalafmt.conf:
##########
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version = 3.7.1
+runner.dialect = scala212
+maxColumn = 96
+docstrings.style = keep
+indent.defnSite = 2
+indent.extendSite = 2

Review Comment:
   I notice that `indent.caseSite` (not overridden here yet) has 4 as its 
default size.  That parameter applies only to a long case expression separated 
by | which spans multiple lines and decides how much to indent the additional 
lines past the "case" on the first line.  Interestingly enough, the parameter's 
example shows a formatted case expression with `indent.caseSite = 5` which 
aligns all the parts of the expression.  It seems like the default value 
should've been 2 rather than 4 for consistency, but I'm not sure what actual 
Daffodil code is using.
   
   The easiest way to find out would be to do a new commit with only a new 
`indent.caseSite = 2` line in this file and see what new changes appear in 
Daffodil files as a result.  If current Daffodil code is already indented 4 
spaces (we would have to check the same files from the main branch before any 
scalafmt formatting was done), then we'll reject the change and keep using 
scalafmt's default value.



##########
.scalafmt.conf:
##########
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version = 3.7.1
+runner.dialect = scala212
+maxColumn = 96
+docstrings.style = keep
+indent.defnSite = 2
+indent.extendSite = 2
+danglingParentheses.callSite = true
+danglingParentheses.defnSite = true
+align.preset = none
+rewrite.rules = [Imports]
+rewrite.imports.sort = ascii
+rewrite.imports.groups = [
+    ["scala\\..*", "java\\..*", "javax\\..*"],
+    ["org\\.apache\\.daffodil\\..*"],
+]
+rewrite.trailingCommas.style = always
+spaces.inImportCurlyBraces = true
+

Review Comment:
   Let's add these parameters in a consistent order such as alphabetically or 
the same order they're listed in the [Configuration - 
Other](https://scalameta.org/scalafmt/docs/configuration.html#other) section.  
In fact, let's put that link in a comment above the parameters so the list's 
always a short click away and remind ourselves which consistent order 
(alphabetically or the list's order, you decide) should be used when 
adding/removing parameters.
   
   Let's remove any parameters which are not changing the parameters' default 
values to something else.  The list tells me that `danglingParentheses.callSite 
= true` and `danglingParentheses.defnSite = true` are the same as their default 
values but the rest can stay.
   
   I also see from the documentation that scalafmt won't rewrite code except 
when breaking lines or explicitly directed by whatever is listed in 
`rewrite.rules = [ ... ]`.  Additional rewrite rules we aren't enabling yet are:
   
   - AvoidInfix
   - PreferCurlyFors
   - RedundantBraces
   - RedundantParens
   - SortModifiers
   
   Another rewrite rule has its own enable parameter: 
rewrite.scala3.convertToNewSyntax.
   
   My thought on enabling any more rewrite rules is that it would be better to 
enable each new rule in a separate commit to make it easier to review the 
incremental changes and decide whether to accept or reject each rewrite rule 
one at a time.  SortModifiers seems like a no-brainer to enable, although we 
should wait until we see the changes it makes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to