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

Convert zoneId String in RepoConfiguration and SummaryJson to ZoneId object #1674

Closed
yhtMinceraft1010X opened this issue Feb 16, 2022 · 5 comments · Fixed by #1790
Closed

Comments

@yhtMinceraft1010X
Copy link
Contributor

yhtMinceraft1010X commented Feb 16, 2022

What feature(s) would you like to see in RepoSense?

I noticed that although zoneId is stored as a ZoneId object in CliArguments.java, it is then converted to a String when stored in RepoConfiguration.java, subsequently, when zoneId needs to be used in places like FileInfoAnalyzer.java, it has to do the conversion back to ZoneId.

Is the feature request related to a problem?

This conversion from ZoneId to String to ZoneId is redundant. In my opinion, it is also quite strange to have zoneId be a String, when the variables that zoneId is commonly used with, sinceDate and untilDate, are LocalDateTime objects.

If possible, describe the solution

Since SummaryJson objects for repos are written into Json files during tests, changing zoneId to be ZoneId instead of String may cause the Json output to be different from expected Json files, potentially breaking the tests.

  • If the above scenario happens, it is okay to keep the zoneId variable as a String in SummaryJson.
  • However, the conversion from String to ZoneId in SummaryJson should be attempted and tested first before reverting back if tests are broken.
  • Recommended approach:
    1. Follow step 2 of the Learning the Basics guide for backend. Throughout this step, take note of how the zoneId variable is used in the code.
    2. Convert zoneId variable from String to ZoneId in RepoConfiguration.java and propagate the change to any classes and methods (inclusive of test code) that break after this change.
    3. Repeat the above steps for SummaryJson.java.
    4. Run tests and checkstyle. Commit these changes if successful.

Additional context

This should be a good first-timer issue for future contributors such as CP3108A/B students. The tracing of the zoneId variable and the subsequent refactoring should provide enough exposure to the backend code.

@yhtMinceraft1010X yhtMinceraft1010X changed the title Convert zoneId String in RepoConfiguration and SummaryJson to ZoneId object. Convert zoneId String in RepoConfiguration and SummaryJson to ZoneId object Feb 16, 2022
@SkyBlaise99
Copy link
Contributor

Hi, I would like to ask if it is ok for me to work on this issue?

@yhtMinceraft1010X
Copy link
Contributor Author

Hi, I would like to ask if it is ok for me to work on this issue?

Sure.

@yhtMinceraft1010X
Copy link
Contributor Author

yhtMinceraft1010X commented Jun 16, 2022

I've edited the recommended approach. It is best to make the zoneId type changes across all files and all relevant changes needed to pass CI within the same commit.

@SkyBlaise99
Copy link
Contributor

Ok thank you 😄

@SkyBlaise99
Copy link
Contributor

SkyBlaise99 commented Jun 16, 2022

Should I keep the setters to allow String inputs? Basically there will be 2 setters for ZoneId.

public void setZoneId(ZoneId zoneId) {
    this.zoneId = zoneId;
}

public void setZoneId(String zoneIdString) {
    this.zoneId = ZoneId.of(zoneIdString);
}

If not, then in some of the test cases there will be

config.setZoneId(ZoneId.of("UTC-0530"));

which is a bit longer than the original

config.setZoneId("UTC-0530");

dcshzj pushed a commit that referenced this issue Jul 14, 2022
zoneId is stored as ZoneId object in CliArguments.java. It is converted 
into String when stored in RepoConfiguration.java. Subsequently, it is 
then converted back to ZoneId when required in FileInfoAnalyzer.java or 
other places.

Such repeated conversion is redundant.

Let's standardize and save zoneId as ZoneId Object across all files.
Punpun1643 pushed a commit to Punpun1643/RepoSense that referenced this issue Jul 17, 2022
zoneId is stored as ZoneId object in CliArguments.java. It is converted 
into String when stored in RepoConfiguration.java. Subsequently, it is 
then converted back to ZoneId when required in FileInfoAnalyzer.java or 
other places.

Such repeated conversion is redundant.

Let's standardize and save zoneId as ZoneId Object across all files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants