GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] Add property to ignore interfaces in FieldDeclarationsShouldBeAtStartOfClassRule by SUPERCILEX · Pull Request #374 · pmd/pmd

Conversation

@SUPERCILEX

@SUPERCILEX SUPERCILEX commented Apr 30, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

fixes #345

@jsotuyod My code looks like this right now which is 😢:

public interface StartCaptureListener {
    void onStartCapture(boolean shouldUploadMediaToTba);
}

private static final int TAKE_PHOTO_RC = 334; // NOPMD https://github.com/pmd/pmd/issues/345
private static final List<String> PERMS; // NOPMD https://github.com/pmd/pmd/issues/345
private static final String MEDIA_CREATOR_KEY = "media_creator"; // NOPMD https://github.com/pmd/pmd/issues/345

private WeakReference<Fragment> mFragment; // NOPMD https://github.com/pmd/pmd/issues/345
private TeamHelper mTeamHelper; // NOPMD https://github.com/pmd/pmd/issues/345
private PermissionRequestHandler mPermHandler; // NOPMD https://github.com/pmd/pmd/issues/345
private WeakReference<OnSuccessListener<TeamHelper>> mListener; // NOPMD https://github.com/pmd/pmd/issues/345
private String mPhotoPath; // NOPMD https://github.com/pmd/pmd/issues/345
private boolean mShouldUploadMediaToTba; // NOPMD https://github.com/pmd/pmd/issues/345

I'm trying to add that property you mentioned, but I'm not sure how to test my code or build pmd for that matter. (I don't even know if what I wrote compiles 😄)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SUPERCILEX
Add property to ignore interfaces in FieldDeclarationsShouldBeAtStart…
fa1e54f
…OfClassRule
@SUPERCILEX

SUPERCILEX commented Apr 30, 2017

Copy link
Copy Markdown
Contributor Author

The travis build passed! 😄

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel self-assigned this May 1, 2017
@adangel adangel added this to the 5.7.0 milestone May 1, 2017
@adangel

adangel commented May 1, 2017

Copy link
Copy Markdown
Member

Awesome! Thanks for contributing!

As for building, all you'll need is maven, and follow this guide: https://github.com/pmd/pmd/blob/master/BUILDING.md

As for unit testing, I'll add a test for this change and reference them here. Then you can see, how this works ;)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

adangel
adangel reviewed May 1, 2017
View reviewed changes
Comment thread ...a/net/sourceforge/pmd/lang/java/rule/design/FieldDeclarationsShouldBeAtStartOfClassRule.java
"Ignore Enum Declarations that precede fields.", true, 1.0f);
private BooleanProperty ignoreAnonymousClassDeclarations = new BooleanProperty("ignoreAnonymousClassDeclarations",
"Ignore Field Declarations, that are initialized with anonymous class declarations", true, 2.0f);
private BooleanProperty ignoreInterfaceDeclarations = new BooleanProperty("ignoreInterfaceDeclarations",

@adangel adangel May 1, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

While writing the unit test, I figured out, that one piece is missing. The properties need to be declared for the rule. This usually happens in the constructor like this:

definePropertyDescriptor(ignoreInterfaceDeclarations);

I'll add this. It's always good to have unit tests :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@adangel
adangel merged commit fa1e54f into pmd:master May 1, 2017
@adangel

adangel commented May 1, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This will be part of PMD 5.7.0

And here's the unit test: 44bb282
It's basically just additional test cases described in XML. The test cases are run via the DesignRulesTest JUnit test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel

adangel commented May 1, 2017

Copy link
Copy Markdown
Member

One more thing: Since this now merged to master and travis has built it (or is still building), it should be included in the latest snapshot binaries

You can set this property in your ruleset.xml like this:

<rule ref="rulesets/java/design.xml/FieldDeclarationsShouldBeAtStartOfClass">
    <properties>
        <property name="ignoreInterfaceDeclarations" value="true"/>
    </properties>
  </rule>
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SUPERCILEX
SUPERCILEX deleted the patch-1 branch May 2, 2017 17:12
@SUPERCILEX

SUPERCILEX commented May 2, 2017

Copy link
Copy Markdown
Contributor Author

@adangel Wow, thanks for all this great information!!! 😄 I'm glad you caught that mistake with not registering the property, and yeah, unit tests are good. 😆 I've never seen them done in XML before, so that's interesting. It looks really simple actually, you just put in some code in the cdata and tell it the number of violations you expect, is that correct?

Thanks again for all your help, being able to build pmd will certainly make it easier to contribute! 😸

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@adangel adangel adangel left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adangel adangel

Labels

None yet

Projects

None yet

Milestone

5.7.0

Development

Successfully merging this pull request may close these issues.

[java] FieldDeclarationsShouldBeAtStartOfClass: Add ability to ignore interfaces

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@SUPERCILEX @adangel
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.