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

Encapsulate test fields #222

Merged

Conversation

sanjanarampurkottur01
Copy link
Contributor

No description provided.

@garydgregory
Copy link
Member

Hello @sanjanarampurkottur01
Why?
This is test code and shows how client classes could be laid out in the wild, with proper or improper adherence to coding guidelines.

@sanjanarampurkottur01
Copy link
Contributor Author

Hello @sanjanarampurkottur01 Why? This is test code and shows how client classes could be laid out in the wild, with proper or improper adherence to coding guidelines.

Hello @garydgregory ,
In my understanding, ensuring optimal code quality across all packages, including test files, is crucial. Therefore, I've decided to refactor the code and incorporate the necessary changes. However, if we neglect the test files, it ultimately comes down to maintaining high overall code quality.

@garydgregory
Copy link
Member

garydgregory commented Nov 22, 2023

Hi @sanjanarampurkottur01
Hm, ok, then you should not only address the one file, but all files:

[ERROR] src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java:[159,23] (design) VisibilityModifier: Variable 'testField' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java:[172,24] (design) VisibilityModifier: Variable 'testField' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/BaseTestCase.java:[68,25] (design) VisibilityModifier: Variable 'rs' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/BaseTestCase.java:[73,25] (design) VisibilityModifier: Variable 'emptyResultSet' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/OutParameterTest.java:[42,23] (design) VisibilityModifier: Variable 'stmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/OutParameterTest.java:[44,26] (design) VisibilityModifier: Variable 'parameter' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[50,22] (design) VisibilityModifier: Variable 'runner' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[51,18] (design) VisibilityModifier: Variable 'handler' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[54,16] (design) VisibilityModifier: Variable 'dataSource' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[56,16] (design) VisibilityModifier: Variable 'conn' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[58,23] (design) VisibilityModifier: Variable 'prepStmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[60,15] (design) VisibilityModifier: Variable 'stmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[62,23] (design) VisibilityModifier: Variable 'meta' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[64,15] (design) VisibilityModifier: Variable 'results' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java:[65,27] (design) VisibilityModifier: Variable 'processor' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java:[67,23] (design) VisibilityModifier: Variable 'metaData' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java:[69,26] (design) VisibilityModifier: Variable 'propDescriptors' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[90,17] (design) VisibilityModifier: Variable 'runner' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[92,18] (design) VisibilityModifier: Variable 'handler' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[95,16] (design) VisibilityModifier: Variable 'dataSource' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[98,16] (design) VisibilityModifier: Variable 'conn' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[101,23] (design) VisibilityModifier: Variable 'prepStmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[104,15] (design) VisibilityModifier: Variable 'stmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[107,23] (design) VisibilityModifier: Variable 'call' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[110,23] (design) VisibilityModifier: Variable 'meta' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[113,15] (design) VisibilityModifier: Variable 'results' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[116,23] (design) VisibilityModifier: Variable 'resultsMeta' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[688,17] (design) VisibilityModifier: Variable 'count' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/MockResultSet.java:[280,74] (blocks) EmptyBlock: Empty if block.
[ERROR] src/test/java/org/apache/commons/dbutils/handlers/columns/AbstractTestColumnHandler.java:[31,25] (design) VisibilityModifier: Variable 'rs' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/handlers/columns/AbstractTestColumnHandler.java:[32,38] (design) VisibilityModifier: Variable 'handler' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/handlers/columns/AbstractTestColumnHandler.java:[33,30] (design) VisibilityModifier: Variable 'matchingType' must be private and have accessor methods.

Make sure you rebase on master please :-)

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (be5d30a) 62.63% compared to head (874c79a) 62.63%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #222   +/-   ##
=========================================
  Coverage     62.63%   62.63%           
  Complexity      411      411           
=========================================
  Files            39       39           
  Lines          1381     1381           
  Branches        104      104           
=========================================
  Hits            865      865           
  Misses          467      467           
  Partials         49       49           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sanjanarampurkottur01
Copy link
Contributor Author

Hi @sanjanarampurkottur01 Hm, ok, then you should not only address the one file, but all files:

[ERROR] src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java:[159,23] (design) VisibilityModifier: Variable 'testField' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/BeanProcessorTest.java:[172,24] (design) VisibilityModifier: Variable 'testField' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/BaseTestCase.java:[68,25] (design) VisibilityModifier: Variable 'rs' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/BaseTestCase.java:[73,25] (design) VisibilityModifier: Variable 'emptyResultSet' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/OutParameterTest.java:[42,23] (design) VisibilityModifier: Variable 'stmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/OutParameterTest.java:[44,26] (design) VisibilityModifier: Variable 'parameter' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[50,22] (design) VisibilityModifier: Variable 'runner' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[51,18] (design) VisibilityModifier: Variable 'handler' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[54,16] (design) VisibilityModifier: Variable 'dataSource' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[56,16] (design) VisibilityModifier: Variable 'conn' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[58,23] (design) VisibilityModifier: Variable 'prepStmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[60,15] (design) VisibilityModifier: Variable 'stmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[62,23] (design) VisibilityModifier: Variable 'meta' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/AsyncQueryRunnerTest.java:[64,15] (design) VisibilityModifier: Variable 'results' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java:[65,27] (design) VisibilityModifier: Variable 'processor' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java:[67,23] (design) VisibilityModifier: Variable 'metaData' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/GenerousBeanProcessorTest.java:[69,26] (design) VisibilityModifier: Variable 'propDescriptors' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[90,17] (design) VisibilityModifier: Variable 'runner' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[92,18] (design) VisibilityModifier: Variable 'handler' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[95,16] (design) VisibilityModifier: Variable 'dataSource' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[98,16] (design) VisibilityModifier: Variable 'conn' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[101,23] (design) VisibilityModifier: Variable 'prepStmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[104,15] (design) VisibilityModifier: Variable 'stmt' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[107,23] (design) VisibilityModifier: Variable 'call' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[110,23] (design) VisibilityModifier: Variable 'meta' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[113,15] (design) VisibilityModifier: Variable 'results' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[116,23] (design) VisibilityModifier: Variable 'resultsMeta' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/QueryRunnerTest.java:[688,17] (design) VisibilityModifier: Variable 'count' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/MockResultSet.java:[280,74] (blocks) EmptyBlock: Empty if block.
[ERROR] src/test/java/org/apache/commons/dbutils/handlers/columns/AbstractTestColumnHandler.java:[31,25] (design) VisibilityModifier: Variable 'rs' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/handlers/columns/AbstractTestColumnHandler.java:[32,38] (design) VisibilityModifier: Variable 'handler' must be private and have accessor methods.
[ERROR] src/test/java/org/apache/commons/dbutils/handlers/columns/AbstractTestColumnHandler.java:[33,30] (design) VisibilityModifier: Variable 'matchingType' must be private and have accessor methods.

Make sure you rebase on master please :-)

That is correct. I will create more PRs for the same.

@garydgregory
Copy link
Member

One PR please, this one.

@sanjanarampurkottur01
Copy link
Contributor Author

One PR please, this one.

Sure. Will do.

@sanjanarampurkottur01
Copy link
Contributor Author

AbstractTestColumnHandler

Hi @garydgregory, I have made changes to the mentioned files. However, the empty if block cannot be fixed since we intend to not do anything for the condition.

@sanjanarampurkottur01
Copy link
Contributor Author

Hi @garydgregory, could you please review the Pull request whenever you have time? Thank you!

@garydgregory garydgregory changed the title Refactoring deficient encapsulation using encapsulate field technique Encapsulate test fields Nov 23, 2023
@garydgregory garydgregory merged commit 1b71a61 into apache:master Nov 23, 2023
6 checks passed
asfgit pushed a commit that referenced this pull request Nov 23, 2023
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.

3 participants