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

Issue #11514: Improve code coverage by adding a new ParseTreeTableModelTest #13074

Merged
merged 1 commit into from
May 25, 2023

Conversation

alimhtsai
Copy link
Contributor

@alimhtsai alimhtsai commented May 21, 2023

Solves issue #11514 Improve code coverage for GUI classes

  • Built successfully with mvn clean verify
  • Added a new ParseTreeTableModelTest
  • Increased the code coverage of ParseTreeTableModel class
$ java -jar checkstyle-10.9.2-all.jar -T InputParseTreeTablePresentation.java 
COMPILATION_UNIT -> COMPILATION_UNIT [1:0]
|--PACKAGE_DEF -> package [1:0]
|   |--ANNOTATIONS -> ANNOTATIONS [1:43]
|   |--DOT -> . [1:43]
|   |   |--DOT -> . [1:39]
|   |   |   |--DOT -> . [1:28]
|   |   |   |   |--DOT -> . [1:22]
|   |   |   |   |   |--DOT -> . [1:11]
|   |   |   |   |   |   |--IDENT -> com [1:8]
|   |   |   |   |   |   `--IDENT -> puppycrawl [1:12]
|   |   |   |   |   `--IDENT -> tools [1:23]
|   |   |   |   `--IDENT -> checkstyle [1:29]
|   |   |   `--IDENT -> gui [1:40]
|   |   `--IDENT -> parsetreetablepresentation [1:44]
|   `--SEMI -> ; [1:70]
`--CLASS_DEF -> CLASS_DEF [6:0]
    |--MODIFIERS -> MODIFIERS [6:0]
    |--BLOCK_COMMENT_BEGIN -> /* [3:0]
    |   |--COMMENT_CONTENT -> *\n* class javadoc\n [3:2]
    |   `--BLOCK_COMMENT_END -> */ [5:0]
    |--LITERAL_CLASS -> class [6:0]
    |--IDENT -> InputParseTreeTablePresentation [6:6]
    `--OBJBLOCK -> OBJBLOCK [6:38]
        |--LCURLY -> { [6:38]
        |--VARIABLE_DEF -> VARIABLE_DEF [9:4]
        |   |--MODIFIERS -> MODIFIERS [9:4]
        |   |--TYPE -> TYPE [9:4]
        |   |   |--BLOCK_COMMENT_BEGIN -> /* [8:4]
        |   |   |   |--COMMENT_CONTENT -> * attribute javadoc [8:6]
        |   |   |   `--BLOCK_COMMENT_END -> */ [8:24]
        |   |   `--LITERAL_INT -> int [9:4]
        |   |--IDENT -> attribute [9:8]
        |   `--SEMI -> ; [9:17]
        |--METHOD_DEF -> METHOD_DEF [14:4]
        |   |--MODIFIERS -> MODIFIERS [14:4]
        |   |   |--BLOCK_COMMENT_BEGIN -> /* [11:4]
        |   |   |   |--COMMENT_CONTENT -> *\n    * method javadoc\n     [11:6]
        |   |   |   `--BLOCK_COMMENT_END -> */ [13:4]
        |   |   `--LITERAL_PUBLIC -> public [14:4]
        |   |--TYPE -> TYPE [14:11]
        |   |   `--LITERAL_VOID -> void [14:11]
        |   |--IDENT -> method [14:16]
        |   |--LPAREN -> ( [14:22]
        |   |--PARAMETERS -> PARAMETERS [14:23]
        |   |--RPAREN -> ) [14:23]
        |   `--SLIST -> { [14:25]
        |       |--BLOCK_COMMENT_BEGIN -> /* [15:8]
        |       |   |--COMMENT_CONTENT ->  just comment  [15:10]
        |       |   `--BLOCK_COMMENT_END -> */ [15:23]
        |       `--RCURLY -> } [16:4]
        `--RCURLY -> } [18:0]

@romani
Copy link
Member

romani commented May 21, 2023

thanks a lot !!
can you remove

checkstyle/pom.xml

Lines 834 to 849 in 70946a8

<!-- Swing related classes -->
<exclude>com.puppycrawl.tools.checkstyle.gui.BaseCellEditor</exclude>
<exclude>com.puppycrawl.tools.checkstyle.gui.CodeSelector</exclude>
<exclude>
com.puppycrawl.tools.checkstyle.gui.ListToTreeSelectionModelWrapper
</exclude>
<exclude>com.puppycrawl.tools.checkstyle.gui.ParseTreeTableModel</exclude>
<exclude>com.puppycrawl.tools.checkstyle.gui.TreeTable</exclude>
<exclude>
com.puppycrawl.tools.checkstyle.gui.TreeTable.TreeTableCellEditor
</exclude>
<exclude>com.puppycrawl.tools.checkstyle.gui.TreeTableCellRenderer</exclude>
<exclude>com.puppycrawl.tools.checkstyle.gui.TreeTableModelAdapter</exclude>
<exclude>
com.puppycrawl.tools.checkstyle.gui.TreeTableModelAdapter.UpdatingTreeModelListener
</exclude>

to make it clear that coverage improved.

and/or:

checkstyle/pom.xml

Lines 868 to 882 in 70946a8

<rule>
<element>CLASS</element>
<includes>
<include>com.puppycrawl.tools.checkstyle.gui.BaseCellEditor</include>
</includes>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.09</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>

if this PR does not cover all, we can just update coverage numbers, make CI green, and improve coverage in next PR (to operate by small PRs)

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

items:

@alimhtsai
Copy link
Contributor Author

Hi @romani,

This PR doesn't cover everything, I only added test cases for the ParseTreeTableModel class.
The method coverage increases from 64% to 88%, and the line coverage increases from 71% to 91%.

Can I remove only <exclude>com.puppycrawl.tools.checkstyle.gui.ParseTreeTableModel</exclude> in the pom.xml?

Thanks!

@romani
Copy link
Member

romani commented May 21, 2023

just update to number got archived, to make sure nobody will not reduce % of coverage in this file in future.

is some lines should stay , it is ok, we will cover them later.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Items

@alimhtsai
Copy link
Contributor Author

Hi @romani,

I've renamed the variable as classDef, and updated the cryptic selection of classDef into util method.
I've checked other chained get calls, and I believed that other parts are used properly.

Thanks.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Items

@alimhtsai
Copy link
Contributor Author

Hi @romani,

I've updated the variable name and modified all other chained get calls to util method.

Thanks.

@alimhtsai alimhtsai requested a review from romani May 23, 2023 07:22
@romani
Copy link
Member

romani commented May 23, 2023

@alimhtsai , please reply done for each review items I opening. I will help a lot for you to double check that nothing is forgotten and for me.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

items:

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Last item:

@romani
Copy link
Member

romani commented May 24, 2023

Please fix inspection CI failure

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Ok to merge if CI pass

@romani romani merged commit b35c2e6 into checkstyle:master May 25, 2023
109 checks passed
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.

None yet

2 participants