Skip to content

Add filter for plain getter and setter #1006

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

Closed
wants to merge 17 commits into from

Conversation

DanielKraft
Copy link

@DanielKraft DanielKraft commented Jan 30, 2020

Plain getter and setter filter

This filter is inspired by the FilteringOptions: Plain getters and setters

Filter criteria

  • Method name starts with get, is or set
  • Method name contains the name of a field
  • Method body contains only standard logic like return name or this.name = name

Examples

private String name;
private boolean valid;

// Ignored because of the name 'getName' and the body
public String getName() {
   return name;  
}

// Ignored because of the name 'setName' and the body
public void setName(String name) {
   this.name = name; 
}

// Not ignored because of the custom body
public void setName(String name) {
   if (name.length() > 0) {
      this.name = name; 
   }
}

// Ignored because of the name 'isValid' and the body
public boolean isValid() {
   return valid; 
}

// Not ignored because of the custom name 'valid'
public boolean valid() {
   return valid; 
}

API

The filter can be disabled via the following APIs.

CLI

report

java -jar jacococli.jar report --disablePlainGetterSetter

Maven

report

<properties>
   <jacoco.disablePlainGetterSetter>true</jacoco.disablePlainGetterSetter>
</properties>

check

<execution>
   <id>check</id>
   <goals>
      <goal>check</goal>
   </goals>
   <configuration>
      <disablePlainGetterSetter>true</disablePlainGetterSetter>
   </configuration>
</execution>

Ant

report

<jacoco:report>
   <structure name="root">
      <filters disablePlainGetterSetter="true" />
   </structure>
</jacoco:report>

@DanielKraft DanielKraft changed the title Add filter for plain getter and setter (#204) Add filter for plain getter and setter Jan 30, 2020
@DanielKraft DanielKraft requested a review from Godin January 30, 2020 12:49

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@DanielKraft DanielKraft requested a review from marchof February 3, 2020 08:40

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@marchof
Copy link
Member

marchof commented Apr 2, 2020

Thanks for the contribution!

As we already decided earlier (see PR #923) we will not add filters for user written source code.

Also as you can see configurable filters are really painful to maintain in the various integrations we have. This approach will obviously not scale if we add more configuration options. Also think of other integrations which are not in this repository (EclEmma, Gradle etc).

Please understand that due to our limited ressources to maintain this project we will cannot add additional complexity to it.

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.

None yet

2 participants