Skip to content

[FLINK-6835] Update code style documentation#63

Merged
asfgit merged 1 commit intoapache:asf-sitefrom
zentol:asf-site
Jul 12, 2017
Merged

[FLINK-6835] Update code style documentation#63
asfgit merged 1 commit intoapache:asf-sitefrom
zentol:asf-site

Conversation

@zentol
Copy link
Contributor

@zentol zentol commented Jun 2, 2017

Updates the code style section in regards to checkstyle.

Also addresses FLINK-3814.

cc1
cc2

Copy link
Contributor

@greghogan greghogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is certainly an improvement corresponding to the updated checkstyle. It seems a bit awkward that we have code style and IDE configuration on the website and in the project documentation.

- **No redundant imports.**
- **No wildcard imports.** They can cause problems when adding to the code and in some cases even during refactoring.
- **Import order.** Imports must be ordered alphabetically, grouped into the following blocks, with each block separated by an empty line:
- <imports from other libraries>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing org.apache.flink imports.

### Naming
- **Package names must start with a letter, and must not contain upper-case letters or special characters.**
- **Non-private static final fields must be upper-case, with words being separated by underscores.** (`MY_STATIC_VARIABLE`)
- **non-static fields/methods must be in lower camcel case.** (`myNonStaticField`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalize non.

- **Comments**. Add comments to your code. What is it doing? Add JavaDocs or inherit them by not adding any comments to the methods. Do not automatically generate comments and avoid unnecessary comments like:

### Javadocs
- **All public/protected methods and classes must have a Javadoc.**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this all non-private?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package private don't require javadocs; whether that is excluded in "non-private" may be up to interpretation.


### Javadocs
- **All public/protected methods and classes must have a Javadoc.**
- **The first sentence of the javadoc must end with a dot.**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'dot' -> 'period'?

@zentol
Copy link
Contributor Author

zentol commented Jun 2, 2017

Where do we reference checkstyle in the project docs? I only found this https://ci.apache.org/projects/flink/flink-docs-release-1.3/internals/ide_setup.html#checkstyle, which IMO we should also move to the website because it isn't relevant for users, which as i understand it is the target audience of the project docs.

<li><strong>No wildcard imports.</strong> They can cause problems when adding to the code and in some cases even during refactoring.</li>
<li><strong>Import order.</strong> Imports must be ordered alphabetically, grouped into the following blocks, with each block separated by an empty line:
<ul>
<li>&lt;imports from flink packages&gt;</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be clearer to state imports from org.apache.flink.*?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, will change it.

@zentol
Copy link
Contributor Author

zentol commented Jun 7, 2017

@greghogan could you take another look?

@tzulitai
Copy link
Contributor

tzulitai commented Jul 2, 2017

@zentol @greghogan what's the status of this PR?

@zentol
Copy link
Contributor Author

zentol commented Jul 4, 2017

@tzulitai IMO it's good to merge.

@uce
Copy link
Contributor

uce commented Jul 11, 2017

I just got around to trying the new setup with IntelliJ and I think it's a very nice improvement compared to what we had before.

+1 to merge

Follow ups:

  • Do we have a page where we give details about how to set up IntelliJ with the checkstyle plugin and importing the code style via checkstyle?
  • I think having this page in the code as opposed to the project page would feel more natural (same as to what @greghogan suggested?). Having it as Markdown and linking to it from the project page would give a nicely formatted page.

@asfgit asfgit merged commit 13fc61c into apache:asf-site Jul 12, 2017
@zentol
Copy link
Contributor Author

zentol commented Jul 12, 2017

@uce We have a guide to setup checkstyle in the IDE setup section of the documentation: https://ci.apache.org/projects/flink/flink-docs-release-1.4/internals/ide_setup.html#checkstyle
This guide will also be extended in apache/flink#4086 once apache/flink#4112 is merged, which I want to do after the build profile reorganization.

I think the checkstlye guide (both what we merged here and the setup guide) belong on the project website. The documentation is primarily geared towards Flink users, there's no need for a checkstyle section in there. The contributor guide on the website seems like a good place for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants