AY2021S1-CS2103T-W16-3 / tp

https://ay2021s1-cs2103t-w16-3.github.io/tp/
MIT License
0 stars 6 forks source link

Ban time travel #289

Closed ianyong closed 4 years ago

ianyong commented 4 years ago

Motivation

Due to the time-sensitive nature of transactions, changing the system time to some point earlier than the date of any existing transaction results in errors being thrown. This is because these transactions would now be "in the future", violating certain assumptions that have been made.

Currently, upon launching Fine$$e, JsonFinanceTrackerStorage validates the data within fine$$e.json. As such, we can be sure that all transactions are valid according to the system time at start-up. However, if the user changes the system time while the application is open, there is a chance that errors will be thrown upon the next command being entered.

Solution

In order to combat this, we keep track of the system time at start-up, and update the last observed time every time the user inputs a command. Should the current time be earlier than the last observed time when the user enters a command, we know that the user has meddled with their system time. Thus, we disable Fine$$e and display the following screen instead:

image

This forces the user to restart the application, whereby the validation from JsonFinanceTrackerStorage kicks in.

Resolves #246.

codecov-io commented 4 years ago

Codecov Report

Merging #289 into master will increase coverage by 0.14%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #289      +/-   ##
============================================
+ Coverage     85.40%   85.54%   +0.14%     
- Complexity      907      916       +9     
============================================
  Files           119      122       +3     
  Lines          2336     2359      +23     
  Branches        313      314       +1     
============================================
+ Hits           1995     2018      +23     
  Misses          220      220              
  Partials        121      121              
Impacted Files Coverage Δ Complexity Δ
...021s1_cs2103_w16_3/finesse/logic/LogicManager.java 82.75% <100.00%> (+1.27%) 9.00 <0.00> (ø)
...1_cs2103_w16_3/finesse/logic/time/SystemClock.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)
...s1_cs2103_w16_3/finesse/logic/time/Timekeeper.java 100.00% <100.00%> (ø) 5.00 <5.00> (?)
...nesse/logic/time/exceptions/TemporalException.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 412f667...e901bb9. Read the comment docs.