Comments (9)
conceptually, after shallow review, I am good with proposal.
can this be a solution https://checkstyle.org/checks/coding/matchxpath.html#MatchXpath ?
you can find bunch of example in our issue tracker and discussions, like #12975 (comment)
from checkstyle.
The Google Conventions also suggest a specific pattern for test methods.
By implementing the proposed Check, those conventions could be enforced via Checkstyle.
Could you please explain a bit on where a specific pattern is mentioned for annotated test methods?
From what I know, google style guide only asks for the method names to follow lowerCamelCase.. am I wrong here?
does not match pattern "^test.*$"
I agree we may use this by convention (even in our code) but enforcing this on all users is a major debate.
Some coding conventions, like the one used for my uni project
Could you please share examples of such style schemes?
from checkstyle.
Could you please explain a bit on where a specific pattern is mentioned for annotated test methods? From what I know, google style guide only asks for the method names to follow lowerCamelCase.. am I wrong here?
The Google Style Guide doesn't specify a pattern for test methods:
There is no One Correct Way to name test methods.
However it suggests that a pattern may be used:
One typical pattern is
<methodUnderTest>_<state>
, for examplepop_emptyStack
does not match pattern "^test.*$"
I agree we may use this by convention (even in our code) but enforcing this on all users is a major debate.
Both the pattern and annotations are properties which can be adjusted to the user's needs.
I think those might be good default values tho. But we can totally change those. It's just the example that prompted me to make a Check like this.
Some coding conventions, like the one used for my uni project
Could you please share examples of such style schemes?
Test methods schould be named "test" + method name.
method that should be tested | test method |
---|---|
removeObject | testRemoveObject |
removeKey | testRemoveKey |
There are some special methods with specific annotations which should always be named the same:
method with annotation | name of the method |
---|---|
@BeforeEach |
setUp() |
@AfterEach |
tearDown() |
@BeforeAll |
setUpAll() |
@AfterAll |
tearDownAll() |
from checkstyle.
Test methods schould be named "test" + method name.
There are some special methods with specific annotations which should always be named the same:
Some coding conventions, like the one used for my uni project, set rules for the naming of test methods,
I have understood your vision previously. Please provide sources/links to such code styles that support your statement above
However it suggests that a pattern may be used:
A bit of clarity here.. the new check wants to focus only on targeted methods ? (I don't think this is what google style implied)
Because we already have a property that allows this CS check to be customized by user with regex for method name identifier?
from checkstyle.
I want only certain annotated methods to be checked. The current MethodName Check doesn't allow that functionality. It will always check methods whether annotated or not.
Actually, the best thing to do would be to extend the current MethodName Check to be able to filter only certain annotated methods. Then a new Check won't be necessary. I suppose this issue could be changed to an extension for MethodName then?
Please provide sources/links to such code styles that support your statement above
I have provided a link to the Google conventions, which mentions a pattern. I cannot link to internal uni project conventions tho. But I am sure there are many conventions for test method out there. Regardless, I think this is a useful feature, allowing users more control.
from checkstyle.
It will always check methods whether annotated or not.
This doesn't need a new check. We make use of certain properties to restrict/limit/enhance/extend existing check accordingly.
I have provided a link to the Google conventions, which mentions a pattern
But I am sure there are many conventions for test method out there
This is where we are stumbling around.. From what I know of the project, we don't introduce new functionalities based on assumptions or very few uni conventions. For a new functionality to be implemented, it needs to be backed up by a reliable code style scheme. I hope you understand what I mean, we can't force users to follow something that is limited to few unis or random conventions.
Regardless, I think this is a useful feature, allowing users more control.
This, however is not in my power to decide, let's wait for the maintainers' opinion.
If they decide it beneficial for the project, then a new property will suffice, new check is not required :)
from checkstyle.
can this be a solution https://checkstyle.org/checks/coding/matchxpath.html#MatchXpath ?
Theoretically yes, we should be able to evaluate an xpath query that matches targeted node
from checkstyle.
can this be a solution https://checkstyle.org/checks/coding/matchxpath.html#MatchXpath ?
I believe so, yes. I have not looked much into Xpaths, but they seem very powerful.
In that case, I think it might be useful to mention them in the documentation more explicitly. I had the impression I would have to change or add a new Check. This would keep users from implementing checks that Xpath could accomplish easily.
conceptually, after shallow review, I am good with proposal.
Does that mean the functionality I described should be added to Checkstlye? Or it should not, since Xpath could do the same?
from checkstyle.
Try to make it by xpath first, such attempt usually shows and items that xpath is not able to do. So reason for new Check will be more explicit.
from checkstyle.
Related Issues (20)
- False positives when first sentence of Javadoc is on a separate line
- ClassLength
- InnerTypeNumber
- Static MethodCount HOT 1
- False negative in UnusedImportCheck
- CLI feature: support stdin HOT 7
- Enforce new naming convention "InputXpath{Checkname}Xxxx.java" in IT area HOT 8
- Indentation: Unexpected violation when class declaration is wrapped after public and before static HOT 15
- [JavadocType] add additional allowedTags feature HOT 2
- new Check: ConstructorsDeclarationGrouping to check the grouping of overloaded constructors HOT 6
- ParenPad incorretly flags unsupported token HOT 4
- Ending period detected in first sentence of Javadoc when it is not at the end of the sentence HOT 1
- First sentence of Javadoc is not checked past default period character when using custom period HOT 1
- New Check: Unnecessary Block Braces HOT 14
- Enhance Command Line documentation by organizing options in Tabular format HOT 9
- EmptyLineSeparator does not detect multiple blank lines HOT 6
- OverloadMethodDeclarationOrder check ignores anything besides methods HOT 2
- IT regression area Folder structure HOT 2
- How to exclude java-Files that contain @Generated-Annotation? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from checkstyle.