kezhenxu94 commented on code in PR #11272: URL: https://github.com/apache/dolphinscheduler/pull/11272#discussion_r938504480
########## style/pre-commit: ########## @@ -0,0 +1,20 @@ +#!/bin/sh +# +# 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. +# + +# A hook script to automatically fix code style and formatting errors with spotless +mvn spotless:apply Review Comment: Prefer `.mvnw` ```suggestion ./mvnw spotless:apply ``` This is not a correct hook. A check hook should prevent the commit if the codes style conflict with the rules but it just fix the codestyle and let the commit succeeds. If the developers think the commit succeeds and then `git push`, the bad style codes are still pushed, leaving the fixed one locally. You can try modify some codes to bad style and try `git add . && git commit -m'Test'`, everything is going to succeed and if you then `git push`, you might don't know the hook script helped you fixed the codes and you might be curious why there are uncommitted codes. Try mine here 👇 ```suggestion if ./mvnw spotless:check; then exit 0 fi ./mvnw spotless:apply exit 1 ``` ########## style/spotless_dolphinscheduler_formatter.xml: ########## @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- +/** + * 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. + */ +--> +<profiles version="13"> + <profile kind="CodeFormatterProfile" name="'DolphinScheduler Apache Current'" version="13"> + <setting id="org.eclipse.jdt.core.compiler.source" value="1.8" /> + <setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8" /> + <setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8" /> + <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true" /> Review Comment: This conflicts with the current style and most IDE settings. Most IDEs trim the blank lines when saving ########## docs/docs/en/development/development-environment-setup.md: ########## @@ -19,14 +19,28 @@ cd dolphinscheduler git clone [email protected]:apache/dolphinscheduler.git ``` -### compile source code +### Compile Source Code Supporting system: * MacOS * Liunx Run `mvn clean install -Prelease -Dmaven.test.skip=true` +### Code Style + +DolphinScheduler uses `Spotless` for code style and formatting checks. +You could run the following command and `Spotless` will automatically fix +the code style and formatting errors for you: + +```shell +mvn spotless:apply Review Comment: Prefer `./mvnw` ```suggestion ./mvnw spotless:apply ``` -- 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]
