-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GRIFFIN-312] Code Style Standardization
**What changes were proposed in this pull request?** This PR targets the following, - fix the various warnings during build and in source code, - perform code formatting as per a standard style, - fix scalastyle integration Using the [code format from spark code style can be automatically imposed on measure module. Link: https://github.com/apache/spark/blob/master/dev/.scalafmt.conf Since ScalaStyle targets scala source code only, it should be a part of the measure module only. Current misconfiguration is also suppressing the formatting errors Scalafmt is used for code formatting. **Does this PR introduce any user-facing change?** No **How was this patch tested?** Griffin test suite. Author: chitralverma <[email protected]> Closes #560 from chitralverma/code-style-standardization.
- Loading branch information
1 parent
ed47c2b
commit 7f718d3
Showing
157 changed files
with
2,891 additions
and
2,573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
align = none | ||
align.openParenDefnSite = false | ||
align.openParenCallSite = false | ||
align.tokens = [] | ||
optIn = { | ||
configStyleArguments = false | ||
} | ||
danglingParentheses = false | ||
docstrings = JavaDoc | ||
maxColumn = 98 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,13 @@ under the License. | |
--> | ||
|
||
# Apache Griffin Development Code Style Config Guide | ||
Griffin product consists of three main parts, they are developed and built on Angular 2/Java/Scala technique. | ||
So it's necessary to define a bunch of code style rules, all codes need to follow those rules and | ||
keep any codes submitted by various committers consistent. | ||
Apache Griffin consists of three main modules - Measure, Services and UI. These are developed using Scala, Java and Angular 2 respectively. | ||
|
||
Quoting the Databricks-Apache Spark Code Style Guide at [link](https://github.com/databricks/scala-style-guide) : | ||
> Code is written once by its author, but read and modified multiple times by lots of other engineers. As most bugs actually come from future modification of the code, we need to optimize our codebase for long-term, global readability and maintainability. The best way to achieve this is to write simple code. | ||
So it's necessary to define a bunch of code style rules, which are to be followed by all contributors and committers so as ot keep the code base consistent. | ||
|
||
|
||
## Config Java Code Style | ||
We suggest developers use automatic tools to check code violation like [CheckStyle](https://github.com/checkstyle/checkstyle).<br> | ||
|
@@ -309,8 +313,59 @@ We suggest developers use automatic tools to check code violation like [CheckSty | |
 | ||
|
||
|
||
## Config Scala Code Style | ||
to do | ||
## Scala Code Style Guide | ||
|
||
Since only Measure module is written in Scala, this guide applies to only the measure module. | ||
For Scala code, Apache Griffin follows the official [Scala style guide](https://docs.scala-lang.org/style/) | ||
and [Apache Spark Scala guide](https://github.com/databricks/scala-style-guide). | ||
|
||
#### Guide Update History | ||
| Version | Date | Changes | | ||
|:-------:|:-----------|:--------| | ||
| 1 | 2019-12-24 | Initial version: Added Scala Code Style Guide | | ||
|
||
#### Configuration | ||
For code style checks Apache Griffin uses [Scalastyle](http://www.scalastyle.org/) and formatting is handled | ||
by [Scalafmt](https://scalameta.org/scalafmt/). | ||
|
||
Configurations for both Scalastyle and Scalafmt are present in the root of Apache Griffin repository. | ||
- Scalastyle Config: `scalastyle-config.xml` | ||
- Scalafmt Config: `.scalafmt.conf` | ||
|
||
#### Formatting and Style Check | ||
|
||
Although automatic formatting and checks are built into the build steps of Apache Griffin, | ||
to manually format Scala code and check for possible style violations, run the following commands. | ||
|
||
``` | ||
## assuming current working directory is griffin root | ||
|
||
cd measure | ||
mvn clean verify -DskipTests | ||
``` | ||
#### IntelliJ IDEA Setup | ||
Navigate to _Settings > Editor > Code Style > Scala_ and follow the screenshots below to ensure coding standards | ||
in the IntelliJ IDEA. | ||
 | ||
 | ||
 | ||
 | ||
 | ||
 | ||
#### Important Notes | ||
1. [Guide Update History](#guide-update-history) section must be updated each time any section of | ||
Scala Code Style Guide is edited. | ||
2. Formatting and code style checks must be ensured each time before submitting or updating a pull request as | ||
violations will cause build failures. | ||
3. If you’re not sure about the right style for something, try to follow the style of the existing codebase. | ||
Look at whether there are other examples in the code that use your feature. | ||
In case of any queries or dilemmas feel free to reach out to the other contributors and committers | ||
on the [[email protected]](mailto:[email protected]) list. | ||
## Config Angular 2 Code Style | ||
to do |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.