-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
16 additions
and
15 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
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 |
---|---|---|
|
@@ -61,6 +61,7 @@ cd jenkins-library | |
git remote add upstream [email protected]:sap/jenkins-library.git | ||
git remote set-url --push upstream no_push | ||
``` | ||
|
||
### EditorConfig | ||
|
||
To ensure a common file format, there is a `.editorConfig` file [in place](../.editorconfig). To respect this file, [check](http://editorconfig.org/#download) if your editor does support it natively or you need to download a plugin. | ||
|
@@ -750,11 +751,11 @@ Code shall contain comments to explain the intention of the code when it is uncl | |
|
||
#### Use the return keyword | ||
|
||
In Groovy it is optional to use the _return_ keyword. Use explicitly the _return_ keyword for better readability. | ||
In Groovy it is optional to use the *return* keyword. Use explicitly the *return* keyword for better readability. | ||
|
||
#### Use def | ||
|
||
When using _def_ in Groovy, the type is Object. Using _def_ simplifies the code, for example imports are not needed, and therefore the development is faster. | ||
When using *def* in Groovy, the type is Object. Using *def* simplifies the code, for example imports are not needed, and therefore the development is faster. | ||
|
||
#### Do not use a visibility modifier for public classes and methods | ||
|
||
|
@@ -790,11 +791,11 @@ Use named parameters for Jenkins Pipeline Steps: | |
|
||
e.g. `sh returnStdout: true, script: command` | ||
|
||
#### Do not use _with()_ operator | ||
#### Do not use *with()* operator | ||
|
||
The _with_ operator is not yet supported by Jenkins, and it must not be used or encapsulated in a @NonCPS method. | ||
The *with* operator is not yet supported by Jenkins, and it must not be used or encapsulated in a @NonCPS method. | ||
|
||
#### Use _==_ operator | ||
#### Use *==* operator | ||
|
||
Use Groovy’s `==` instead of Java `equals()` to avoid NullPointerExceptions. To compare the references of objects, instead of `==`, you should use `a.is(b)` [[1]](http://groovy-lang.org/style-guide.html). | ||
|
||
|
@@ -833,7 +834,7 @@ For a complete description of all available methods, please read the GDK API [[5 | |
|
||
#### Use Groovy's switch | ||
|
||
Groovy’s switch accepts any kind of type, thereby is more powerful. In this case, the use of _def_ instead of a type is necessary. | ||
Groovy’s switch accepts any kind of type, thereby is more powerful. In this case, the use of *def* instead of a type is necessary. | ||
|
||
#### Use alias for import | ||
|
||
|
@@ -843,19 +844,19 @@ In Groovy, it is possible to assign an alias to imported packages. Use alias for | |
|
||
In Groovy a null, void, equal to zero, or empty object evaluates to false, and if not, evaluates to true. Instead of writing null and size checks e.g. `if (name != null && name.length > 0) {}`, use just the object `if (name) {}`. | ||
|
||
#### Use _?._ operator | ||
#### Use *?.* operator | ||
|
||
Use the safe dereference operator _?._, to simplify the code for accessing objects and object members safely. Using this operator, the Groovy compiler checks null objects and null object members, and returns _null_ if the object or the object member is null and never throws a NullPointerException. | ||
Use the safe dereference operator *?.*, to simplify the code for accessing objects and object members safely. Using this operator, the Groovy compiler checks null objects and null object members, and returns *null* if the object or the object member is null and never throws a NullPointerException. | ||
|
||
#### Use _?:_ operator | ||
#### Use *?:* operator | ||
|
||
Use Elvis operator _?:_ to simplify default value validations. | ||
Use Elvis operator *?:* to simplify default value validations. | ||
|
||
#### Use _any_ keyword | ||
#### Use *any* keyword | ||
|
||
If the type of the exception thrown inside a try block is not important, catch any exception using the _any_ keyword. | ||
If the type of the exception thrown inside a try block is not important, catch any exception using the *any* keyword. | ||
|
||
#### Use _assert_ | ||
#### Use *assert* | ||
|
||
To check parameters, return values, and more, use the assert statement. | ||
|
||
|
@@ -869,4 +870,4 @@ To check parameters, return values, and more, use the assert statement. | |
|
||
[4] Jenkins Pipeline's syntax: [https://jenkins.io/doc/book/pipeline/syntax/](https://jenkins.io/doc/book/pipeline/syntax/) | ||
|
||
[5] GDK: Groovy Development Kit: [http://groovy-lang.org/groovy-dev-kit.html](http://groovy-lang.org/groovy-dev-kit.html) | ||
[5] GDK: Groovy Development Kit: [http://groovy-lang.org/groovy-dev-kit.html](http://groovy-lang.org/groovy-dev-kit.html) |