-
Notifications
You must be signed in to change notification settings - Fork 45
Add basic code style helper guide and default linters #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,53 @@ | ||
# Contributors Guide | ||
|
||
This guide aims to guide newcomers to getting started with the project standards. | ||
|
||
|
||
## Code Style | ||
|
||
For this project we use basically the default configuration for most used IDEs. | ||
For the configurations below, make sure to properly configure your IDE: | ||
|
||
- **imports**: goimports | ||
|
||
This should be enough to get you started. | ||
|
||
If you are unsure that your IDE is not correctly configured, you can run the lint checks: | ||
|
||
```bash | ||
make lint | ||
``` | ||
|
||
If something goes wrong, the error will be printed, e.g.: | ||
```bash | ||
$ make lint | ||
make addheaders | ||
make fmt | ||
./hack/go-lint.sh | ||
util/floatstr/floatstr_test.go:19: File is not `goimports`-ed (goimports) | ||
"k8s.io/apimachinery/pkg/util/yaml" | ||
make: *** [lint] Error 1 | ||
``` | ||
|
||
Lint issues can be fixed with the `--fix` flag, this command can be used: | ||
```bash | ||
make lint params=--fix | ||
``` | ||
|
||
|
||
### EditorConfig | ||
For IntelliJ you can find an example `editorconfig` file [here](contrib/intellij.editorconfig). To use it please visit | ||
the Jetbrains [documentation](https://www.jetbrains.com/help/idea/editorconfig.html). | ||
|
||
|
||
## Known Issues | ||
|
||
On MacOSX/darwin you might get this issue: | ||
``` | ||
goimports: can't extract issues from gofmt diff output | ||
``` | ||
To solve install the `diffutils` package: | ||
|
||
```bash | ||
brew install diffutils | ||
``` |
This file contains hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
root = true | ||
|
||
[{*.go,*.go2}] | ||
indent_style = tab | ||
ij_continuation_indent_size = 4 | ||
ij_go_GROUP_CURRENT_PROJECT_IMPORTS = true | ||
ij_go_add_leading_space_to_comments = true | ||
ij_go_add_parentheses_for_single_import = false | ||
ij_go_call_parameters_new_line_after_left_paren = true | ||
ij_go_call_parameters_right_paren_on_new_line = true | ||
ij_go_call_parameters_wrap = off | ||
ij_go_fill_paragraph_width = 80 | ||
ij_go_group_stdlib_imports = true | ||
ij_go_import_sorting = goimports | ||
ij_go_keep_indents_on_empty_lines = false | ||
ij_go_local_group_mode = project | ||
ij_go_move_all_imports_in_one_declaration = true | ||
ij_go_move_all_stdlib_imports_in_one_group = false | ||
ij_go_remove_redundant_import_aliases = true | ||
ij_go_run_go_fmt_on_reformat = true | ||
ij_go_use_back_quotes_for_imports = false | ||
ij_go_wrap_comp_lit = off | ||
ij_go_wrap_comp_lit_newline_after_lbrace = true | ||
ij_go_wrap_comp_lit_newline_before_rbrace = true | ||
ij_go_wrap_func_params = off | ||
ij_go_wrap_func_params_newline_after_lparen = true | ||
ij_go_wrap_func_params_newline_before_rparen = true | ||
ij_go_wrap_func_result = off | ||
ij_go_wrap_func_result_newline_after_lparen = true | ||
ij_go_wrap_func_result_newline_before_rparen = true |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
"net/http" | ||
"os" | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/yaml" | ||
|
||
"strings" | ||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.