Skip to content
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

[#658] Modify checkstyle configuration #1094

Merged
merged 4 commits into from
Mar 5, 2020

Conversation

jamessspanggg
Copy link
Contributor

@jamessspanggg jamessspanggg commented Feb 22, 2020

Fixes #658

The checkstyle for Java files does not check for line-wrap indentation
length.

Let's add the configuration to set line-wrap indentations to be 8 
spaces.

@jamessspanggg
Copy link
Contributor Author

@fzdy1914 @jylee-git @eugenepeh may I ask if there's any other modifications needed for the existing checkstyle?

@fzdy1914
Copy link
Member

No other suggestion from my side.

Copy link
Member

@eugenepeh eugenepeh left a comment

Choose a reason for hiding this comment

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

Good catch, didn't realized that line wrap haven't been included in checkstyle.
No comment on my end but can check the Addressbook's checkstyle in case we missed out anything.

@jamessspanggg
Copy link
Contributor Author

jamessspanggg commented Feb 22, 2020

No comment on my end but can check the Addressbook's checkstyle in case we missed out anything.

Went through with the OSS Java coding standard and every check seems to be there.

Comparing with the addressbook's checkstyle.xml, they set warning severity for some invalid coding standards where RepoSense did not set as warning severity.

Screen Shot 2020-02-23 at 12 04 54 AM

Also, should I create an issue/PR in AddressBook as they are also missing the 8 space line wrap indentation check? [Update: done so]

@jamessspanggg jamessspanggg marked this pull request as ready for review February 22, 2020 16:10
@jamessspanggg jamessspanggg requested a review from a team February 22, 2020 16:11
@Tejas2805
Copy link
Contributor

I am not sure about this rule for line-wrap, therefore just want to confirm. Shouldn't indentation and line wrap indentation be same?

@eugenepeh
Copy link
Member

eugenepeh commented Feb 22, 2020

I am not sure about this rule for line-wrap, therefore just want to confirm. Shouldn't indentation and line wrap indentation be same?

Line wrap is supposed to use double the indentation to distinct itself as line wrap and not the subordinate of previous line

@eugenepeh
Copy link
Member

Comparing with the addressbook's checkstyle.xml, they set warning severity for some invalid coding standards where RepoSense did not set as warning severity.

The rules on addressbook are meant to be more relax for flexible learning. Its not strictly enforce like RepoSense as we're doing actual production

@jamessspanggg jamessspanggg requested a review from a team February 23, 2020 08:40
@@ -44,7 +44,7 @@
private static final Path WITHOUT_FORMATS_TEST_CONFIG_FILES = new File(RepoConfigurationTest.class.getClassLoader()
.getResource("RepoConfigurationTest/repoconfig_withoutformats_test").getFile()).toPath();
private static final Path GROUPS_TEST_CONFIG_FILES = new File(RepoConfigurationTest.class.getClassLoader()
.getResource("RepoConfigurationTest/repoconfig_groups_test").getFile()).toPath();
.getResource("RepoConfigurationTest/repoconfig_groups_test").getFile()).toPath();
Copy link
Contributor

@anubh-v anubh-v Feb 23, 2020

Choose a reason for hiding this comment

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

What is our required indentation level when we have multiple consecutive line wraps?

For example,

private static final Path GROUPS_TEST_CONFIG_FILES = new File(RepoConfigurationTest.class.getClassLoader()
            .getResource("RepoConfigurationTest/repoconfig_groups_test").getFile())
            .toPath();

Should the line toPath(); be indented 8 spaces to the right relative to .getResource(... or should it be on the same level as .getResource(... ?

With the new setting, checkstyle recommends that toPath(); should be on the same level as .getResource(...
This seems ok to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should the line toPath(); be indented 8 spaces to the right relative to .getResource(... or should it be on the same level as .getResource(... ?

It should be 8 spaces to the right relative to the first line, aka private static final...

@anubh-v
Copy link
Contributor

anubh-v commented Feb 23, 2020

Based on some testing I did, seems that the lineWrappingIndentation check will cause an error if we have fewer than 8 spaces' indentation. However, if we have more than 8 spaces' indentation, no error is thrown.

Is this intended?

@jamessspanggg
Copy link
Contributor Author

Is this intended?

Good catch. Think we should set it to be exactly 8 spaces.

@jamessspanggg
Copy link
Contributor Author

It seems that the lineWrappingIndentation will raise an error if we have fewer than 8 spaces' indentation. However, if we have more than 8 spaces' indentation, no error is thrown.

I've tried to set the exact 8 space indentation rule using forceStrictCondition = "true". However, with this rule, further line-wraps will still need to be exactly 8 spaces from the first line (examples shown below).

Success checkstyle

config.setIgnoreCommitList(
                Collections.singletonList(
                new CommitHash(FAKE_AUTHOR_BLAME_TEST_FILE_COMMIT_08022018_STRING.substring(0, 8))));

Failed checkstyle, the new should be at same indentation as Collections.single...

config.setIgnoreCommitList(
                Collections.singletonList(
                        new CommitHash(FAKE_AUTHOR_BLAME_TEST_FILE_COMMIT_08022018_STRING.substring(0, 8))));

This is a limitation with the Java checkstyle where it can't detect further line-wraps. I guess we can stick with the current "loose" rule for 8 space line wrap indentations to take into account these situations?

@anubh-v
Copy link
Contributor

anubh-v commented Feb 24, 2020

I guess we can stick with the current "loose" rule for 8 space line wrap indentations to take into account these situations?

I'm ok with this approach.

@jamessspanggg jamessspanggg requested review from a team and eugenepeh February 28, 2020 16:33
@fzdy1914 fzdy1914 merged commit 1c130c2 into reposense:master Mar 5, 2020
Tejas2805 added a commit to Tejas2805/RepoSense that referenced this pull request Mar 6, 2020
* 'master' of https://github.com/reposense/RepoSense:
  [reposense#1047] v_summary: simplify toDisplay user logic (reposense#1051)
  [reposense#658] Modify checkstyle configuration (reposense#1094)
  Add commit message length configuration border (reposense#1048)
  [reposense#1061] build.gradle: remove unused dependency (reposense#1095)
  [reposense#1044] Update date hashes on reset date range (reposense#1068)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checkstyle does not pick up incorrect number of indentations
5 participants