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

[#9493] Convert FieldValidator to a utility class #9498

Closed
wants to merge 13 commits into from

Conversation

VinodKW
Copy link
Contributor

@VinodKW VinodKW commented Feb 25, 2019

Fixes #9493 Covert FieldValidator to a utility class Also modified all files which are related to FieldValidator class.

@teammates-bot
Copy link

Hi @VinodkumarWagh, these parts of your pull request do not appear to follow our contributing guidelines:

  1. PR Title
    • Issue Reference (#<issue-number>) missing.

@RonakLakhotia
Copy link
Contributor

@VinodkumarWagh please look take care of the following.

  1. Fix lint errors
  2. See the build details to check your errors
  3. Update your PR title

Copy link
Contributor

@amrut-prabhu amrut-prabhu left a comment

Choose a reason for hiding this comment

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

Make sure that your code compiles before you push changes to your PR.
The changes that you've made here are not sufficient and do not resolve the issue.

As mentioned in the issue description, there are 3 steps needed for FieldValidator:

  • all methods are static
  • the class is final
  • and the constructor is private
    You will also need to fix other places that break once you make these changes.

@VinodKW VinodKW changed the title Updated [#9493] Convert FieldValidator to a utility class Feb 25, 2019
@VinodKW
Copy link
Contributor Author

VinodKW commented Feb 25, 2019

@RonakLakhotia @amrut-prabhu @wangsha Can anybody help me to solve that lint error? How do I resolve it? I'm only getting that one error, except that error all things are going fine.

@rrtheonlyone
Copy link
Contributor

Hi @VinodkumarWagh, to fix the lint error you should refer to your TRAVIS report. This is the output:

[ant:checkstyle] [ERROR] /home/travis/build/TEAMMATES/teammates/src/main/java/teammates/common/util/FieldValidator.java:414: Line has trailing whitespaces. [RegexpSinglelineJava]
[ant:checkstyle] [ERROR] /home/travis/build/TEAMMATES/teammates/src/main/java/teammates/common/util/FieldValidator.java:416: 'METHOD_DEF' has more than 1 empty lines before. [EmptyLineSeparator]
[ant:checkstyle] [ERROR] /home/travis/build/TEAMMATES/teammates/src/main/java/teammates/common/util/FieldValidator.java:708: Line is longer than 125 characters (found 126). [LineLength]

In future, make sure to run ./gradlew lint and npm run lint locally before pushing in your code and creating a PR!

@monmanuela
Copy link
Contributor

Just a nifty trick that may be useful in the future, you can run npm run lint:ts -- --fix to automatically fix some of the lint errors 😄

@VinodKW
Copy link
Contributor Author

VinodKW commented Feb 27, 2019

@amrut-prabhu I've tried each and every combination for the given error still not getting it, what could be wrong in it?
[ant:checkstyle] [ERROR] /home/vinod/teammates/src/main/java/teammates/common/util/FieldValidator.java:264:5: Static variable definition in wrong order. [DeclarationOrder]

@amrut-prabhu
Copy link
Contributor

@VinodkumarWagh This may help.

See the order mentioned under

Checks that the parts of a class or interface declaration appear in the order suggested by the Code Conventions for the Java Programming Language.

@VinodKW
Copy link
Contributor Author

VinodKW commented Feb 27, 2019

@amrut-prabhu I've tried that too and also tried it again by implementing it according to the file that you had suggested to me(TimeHelper.java).

@amrut-prabhu
Copy link
Contributor

Are you sure about that? The link says to place constructors after class variables

@VinodKW
Copy link
Contributor Author

VinodKW commented Feb 27, 2019

@amrut-prabhu got it, I apologize, btw thanks!

Copy link
Contributor Author

@VinodKW VinodKW left a comment

Choose a reason for hiding this comment

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

@amrut-prabhu Changes have made successfully.

@wkurniawan07 wkurniawan07 added the s.ToReview The PR is waiting for review(s) label Feb 27, 2019
Copy link
Contributor

@amrut-prabhu amrut-prabhu left a comment

Choose a reason for hiding this comment

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

Good attempt at the updates!
But, try not to make unintended changes (like unnecessarily removing whitespace or pasting something by accident as mentioned in the first couple of review comments)

src/main/java/teammates/common/util/FieldValidator.java Outdated Show resolved Hide resolved
src/main/java/teammates/common/util/FieldValidator.java Outdated Show resolved Hide resolved
src/main/java/teammates/common/util/FieldValidator.java Outdated Show resolved Hide resolved
@@ -142,7 +144,6 @@
public static final String TEAM_NAME_IS_VALID_EMAIL_ERROR_MESSAGE =
"The field " + TEAM_NAME_FIELD_NAME + " is not acceptable to TEAMMATES as the suggested value for "
+ TEAM_NAME_FIELD_NAME + " can be mis-interpreted as an email.";

Copy link
Contributor

Choose a reason for hiding this comment

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

here too, and the rest of them as well

src/main/java/teammates/common/util/FieldValidator.java Outdated Show resolved Hide resolved
@Test
public void testGetValidityInfoForNonHtmlField_cleanInput_returnEmptyString() {
String clean = "Valid clean input with no special HTML characters";
String testFieldName = "Inconsequential test field name";
String actual = validator.getValidityInfoForNonHtmlField(testFieldName, clean);
String actual = getValidityInfoForNonHtmlField(testFieldName, clean);
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above.

addNonEmptyError(validator.getValidityInfoForNonNullField(
FieldValidator.FEEDBACK_SESSION_NAME_FIELD_NAME, feedbackSessionName), errors);
addNonEmptyError(FieldValidator.getValidityInfoForNonNullField(
FieldValidator.FEEDBACK_SESSION_NAME_FIELD_NAME, feedbackSessionName), errors);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the extra indent?


addNonEmptyError(validator.getValidityInfoForNonNullField(FieldValidator.COURSE_ID_FIELD_NAME, courseId), errors);
addNonEmptyError(FieldValidator.getValidityInfoForNonNullField(
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to just move FieldValidator.getValidityInfoForNonNullField( to the next line as well


addNonEmptyError(validator.getValidityInfoForNonNullField("instructions to students", instructions), errors);
addNonEmptyError(FieldValidator.getValidityInfoForNonNullField(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@@ -175,25 +175,23 @@ public boolean isEnrollInfoSameAs(StudentAttributes otherStudent) {
// id is allowed to be null when the student is not registered
Assumption.assertNotNull(team);
Assumption.assertNotNull(comments);

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't remove this whitespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amrut-prabhu Thanks for the review, I will surely correct them all.

@VinodKW
Copy link
Contributor Author

VinodKW commented Feb 28, 2019

@amrut-prabhu Why Travis-CI is not showing the report?

Copy link
Contributor Author

@VinodKW VinodKW left a comment

Choose a reason for hiding this comment

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

Ready to review.

@wkurniawan07
Copy link
Member

@VinodkumarWagh Until Travis CI gives green, it is not ready for review (unless you requested for partial review, which seems not to be the case). There are merge conflicts that you need to resolve.

@VinodKW
Copy link
Contributor Author

VinodKW commented Feb 28, 2019

@wkurniawan07 But it's been hours now for Travis CI to give the green light, is there any problem with it? Because I had push that changes hours ago.

@wkurniawan07
Copy link
Member

@VinodkumarWagh if there are merge conflicts, no CI would be able to run.

@VinodKW VinodKW closed this Mar 1, 2019
@VinodKW
Copy link
Contributor Author

VinodKW commented Mar 1, 2019

@wkurniawan07 I am creating a new pull request for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.ToReview The PR is waiting for review(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants