-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
No java util date rule test #5
No java util date rule test #5
Conversation
Syncing my fork to the original repository
…coveralls analysis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks a lot for your first contribution to our project !!! It's much appreciated !!
please have a look at the comments I've provided. Also, please check the code formatting - a lot of the lines changed are actually only some formatting changes. We'll probably have to provide an automated code style check
ArchUtils.NO_JAVA_UTIL_DATE_VIOLATION_MESSAGE + " - class: " | ||
+ methodCall.getOriginOwner().getName() + " - line: " | ||
+ methodCall.getLineNumber())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code from lines 60-71 is not unit tested properly : I've commented it locally, and the tests are still passing. so please add a test for that use case, or remove that part of the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a pleasure to contribute to this project. The source code format is automatically defined by Eclipse. I will also focus on these tests. Thanks for your idea.
List<JavaField> classesWithJavaUtilDateFields = item.getAllFields().stream() | ||
.filter(field -> isJavaUtilDateField(field)).collect(toList()); | ||
|
||
for (JavaField field : classesWithJavaUtilDateFields) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do it in 2 steps ? instead of collecting the items, you could directly a foreach and add the violations in events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great
} | ||
|
||
@Test(expected = Throwable.class) | ||
public void shouldThrowNoJavaUtilDateViolation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the added value of that test compared to previous one ? It's same, no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I'll delete this second test.
I made some changes on NoJavaUtilDateRuleTest.java and NoJavaUtilDateRuleTestTest.java about the tests and code style.
Thank you very much @vincent-fuchs , what do you think about the changes I've made ? |
}); | ||
} | ||
|
||
@SuppressWarnings("deprecation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the SuppressWarnings annotation and modify your code so that no deprecation warning comes up.
Thanks for the changes, but there is still one thing I don't get :
Also :
|
…TestTest.java / ArchUtilsTest.java / ObjectWithAdateField.java / ObjectWithJavaUtilDateReferences.java NoJavaUtilDateRuleTest.java : 1) No method is imported using the java.util.Date library so I deleted code related to the cheking of imported methods 2) I created a constant NO_JAVA_UTIL_DATE_VIOLATION_MESSAGE 3) I used SRC_CLASSES_FOLDER from ArchRuleTest NoJavaUtilDateRuleTestTest.java : I deleted ObjectWithJavaUtilDateReferences.java and created ObjectWithAdateField.java ArchUtilsTest.java : changed NumberOfRulesAvailable from 9 to 10 & totalClassesInPathWhenPackageFolderDoesNotExists from 16 to 17
@vincent-fuchs I applied new changes related to : NoJavaUtilDateRuleTest.java / NoJavaUtilDateRuleTestTest.java / ArchUtilsTest.java / ObjectWithAdateField.java / ObjectWithJavaUtilDateReferences.java NoJavaUtilDateRuleTest.java :
NoJavaUtilDateRuleTestTest.java : I deleted ObjectWithJavaUtilDateReferences.java and created ObjectWithAdateField.java ArchUtilsTest.java : I changed NumberOfRulesAvailable from 9 to 10 & totalClassesInPathWhenPackageFolderDoesNotExists from 16 to 17 |
Thanks @FanJups ! We'll do a release soon, you'll be able to use it directly |
Thanks @vincent-fuchs , that's great |
New rule added : no java util date (#5)
adding "Official maintainers" section
Summary
java.util.Date is deprecated so I decided to add a new rule NoJavaUtilDateRuleTest.java and suggested other libraries :
java.time ( java 8)
java.util.GregorianCalendar
java.Text.DateFormat
Details
I created a new rule file src/main/java/ com.societegenerale.commons.plugin.rules.NoJavaUtilDateRuleTest.java and added a new String constant (NO_JAVA_UTIL_DATE_VIOLATION_MESSAGE) in src/main/java/com.societegenerale.commons.plugin.utils.ArchUtils.java
I created src/test/java/com.societegenerale.commons.plugin.rules.NoJavaUtilDateRuleTestTest.java to test the rule and changed NumberOfRulesAvailable from 9 to 10 & totalClassesInPathWhenPackageFolderDoesNotExists from 12 to 13 in src/test/java/com.societegenerale.commons.plugin.rules.ArchUtilsTest.java
I created 3 files ObjectWithJavaTextDateFormat.java ; ObjectWithJavaUtilDateReferences.java and ObjectWithJavaUtilGregorianCalendar.java in src/test/java/com.societegenerale.commons.plugin.rules.classesForTests
I added my email in pom.xml
Context
java.util.Date library is deprecated
Use Java8 java.time or java.util.GregorianCalendar or java.text.DateFormat to parse and format dates instead of java.util.Date library because they support internationalization better
Checklist:
Related issue :