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

Added extended reports filtering #581

Merged
merged 13 commits into from
May 14, 2024
Merged

Added extended reports filtering #581

merged 13 commits into from
May 14, 2024

Conversation

shanshin
Copy link
Collaborator

The following report filtering features have been implemented:

  • include filter by classes annotated with specified annotations
  • include and exclude filters by classes that inherit the specified class or implement the specified interface

Resolves #274
Resolves #454

@shanshin shanshin requested a review from sandwwraith March 22, 2024 13:39

@Option(
name = "--excludeInheritedFrom",
usage = "filter to exclude classes inheriting the specified class or implementing an interface, wildcards `*` and `?` are acceptable",
Copy link
Member

Choose a reason for hiding this comment

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

[nit] since you differ class and interface, maybe its better to use standard JVM terminology "... extending the specified class or implementing an interface"

@@ -186,17 +186,62 @@ public static class ClassFilters {
*/
public final Set<String> excludeClasses;

/**
* Classes that have at least one of the annotations specified in this field are presents in the report.
* All other classes that are not marked with at least one of the specified annotations are not included in the report.
Copy link
Member

Choose a reason for hiding this comment

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

What happens when both excludeAnnotation and includeAnnotation are specified? I know it is mentioned in markdown docs, but it would nice to have it here also

kover-gradle-plugin/docs/configuring.md Outdated Show resolved Hide resolved
kover-gradle-plugin/docs/configuring.md Outdated Show resolved Hide resolved
@@ -46,12 +46,19 @@ koverReport {
packages("com.another.subpackage")
// excludes all classes and functions, annotated by specified annotations (with BINARY or RUNTIME AnnotationRetention), wildcards '*' and '?' are available
annotatedBy("*Generated*")
// exclude all classes that inherit the specified class or implement the specified interface
inheritedFrom("*Repository")
Copy link
Member

Choose a reason for hiding this comment

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

You specified inheritedFrom("*Repository") in both excludes and includes. This makes the example very strange.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, these docs should be fully rewritten

@@ -37,18 +38,50 @@ internal class ReportAnnotationFilterTests {
}
}
}
}

class Foo : AutoCloseable {
Copy link
Member

Choose a reason for hiding this comment

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

I do not see this class being used in test, accidental leftover?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Dark experiments )))

* inheritedFrom("*Repository")
* ```
*
* **_Does not work for JaCoCo_**
Copy link
Member

Choose a reason for hiding this comment

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

I believe that the fact that this doesn't work for JaCoCo should be mentioned in the text in this section: https://github.com/Kotlin/kotlinx-kover/blob/main/kover-gradle-plugin/docs/configuring.md#reports-filtering
Actually, this whole block:

It is acceptable to filter a class from the report by its fully-qualified name - using classes or packages. Also acceptable to filter a class, function or getter marked with the specified annotation - annotatedBy.

needs to be expanded with a new functionality

@shanshin shanshin requested a review from sandwwraith March 26, 2024 18:09
@shanshin
Copy link
Collaborator Author

Tests will fail for now, until reporter be fixed

@sandwwraith
Copy link
Member

And when reporter will be fixed?

@shanshin shanshin force-pushed the features-instead-intellij branch from 6e49c2e to 198a96d Compare March 27, 2024 18:28
Base automatically changed from features-instead-intellij to main March 27, 2024 18:33
@shanshin shanshin force-pushed the extended-filters branch from 01d4263 to 779b271 Compare May 1, 2024 12:47
shanshin and others added 9 commits May 4, 2024 19:53
The following report filtering features have been implemented:
- include filter by classes annotated with specified annotations
- include and exclude filters by classes that inherit the specified class or implement the specified interface

Resolves #274
Resolves #454
Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
@shanshin shanshin force-pushed the extended-filters branch from 5c2dca6 to e995c36 Compare May 4, 2024 18:04
kover-cli/docs/index.md Outdated Show resolved Hide resolved
kover-cli/docs/index.md Outdated Show resolved Hide resolved
| --excludeInheritedFrom <exclude-ancestor-name> | filter to exclude classes extending the specified class or implementing an interface, wildcards `*` and `?` are acceptable | | + |
| --includeInheritedFrom <include-ancestor-name> | filter to include only classes extending the specified class or implementing an interface, wildcards `*` and `?` are acceptable | | + |
| --html <html-dir> | generate a HTML report in the specified path | | |
| --include <class-name> | filter to include classes, wildcards `*` and `?` are acceptable | | + |
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be placed next to --exclude?

| --include <class-name> | filter to include classes, wildcards `*` and `?` are acceptable | | + |
| --src <sources-path> | location of the source files root | + | + |
| --title <html-title> | title in the HTML report | | |
| --xml <xml-file-path> | generate a XML report in the specified path | | |
Copy link
Member

Choose a reason for hiding this comment

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

What happens if I specify both --xml and --html? Both reports will be generated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep

kover-gradle-plugin/docs/configuring.md Outdated Show resolved Hide resolved
/**
* Filter classes extending at least one of the specified classes or implementing at least one of the interfaces.
*
* The entire inheritance tree is analyzed, that is, a class may not extend the specified class directly.
Copy link
Member

Choose a reason for hiding this comment

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

Copy my comments from the similar section in docs

shanshin and others added 2 commits May 8, 2024 18:32
Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
@shanshin shanshin requested a review from sandwwraith May 8, 2024 16:58
*
*
* The entire inheritance tree is analyzed; a class may inherit the specified class/interface indirectly and still be included in the report, unless the specified class/interface is located outside of the application (see below).
* The entire inheritance tree is analyzed; a class may inherit the specified class/interface indirectly and still be included in the report, unless the specified class/interface is located outside the application (see below).
Copy link
Member

Choose a reason for hiding this comment

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

of removal was unnecessary

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just wanted the IDEA to stop highlighting this text :)

Moot point, but I will return of. As I understand it, both options are acceptable.

kover-gradle-plugin/docs/configuring.md Outdated Show resolved Hide resolved
* inheritedFrom("*Repository")
* ```
*
* **_Does not work for JaCoCo_**
Copy link
Member

Choose a reason for hiding this comment

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

I believe this note should be placed before the example

* inheritedFrom("*Repository")
* ```
*
* **_Does not work for JaCoCo_**
Copy link
Member

Choose a reason for hiding this comment

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

Move before the example

shanshin and others added 2 commits May 14, 2024 19:01
Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
@shanshin shanshin requested a review from sandwwraith May 14, 2024 17:03
@shanshin shanshin merged commit 17c8ace into main May 14, 2024
1 check passed
@shanshin shanshin deleted the extended-filters branch May 14, 2024 22:31
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.

Add a report filter by parent class or interface Allow for classes to be Included by annotation
2 participants