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

Fix bug when max scores were negative, and feedback given #111

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

lm-44
Copy link

@lm-44 lm-44 commented Oct 21, 2024

Negative max scores caused a bug

As a side-effect of the fix, error messages may not be as specific, specifically, entering a negative score for the grade command

Negative max scores caused a bug

As a side-effect of the fix, error messages may not be as specific,
specifically, entering a negative score for the grade command
@lm-44 lm-44 linked an issue Oct 21, 2024 that may be closed by this pull request
@lm-44 lm-44 added this to the v1.4 milestone Oct 21, 2024
@lm-44 lm-44 added type.Bug A bug severity.High A flaw that affects most users and causes major problems for users labels Oct 21, 2024
@lm-44 lm-44 self-assigned this Oct 21, 2024
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 65.00000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...in/java/seedu/address/logic/parser/ParserUtil.java 55.55% 4 Missing ⚠️
...a/seedu/address/storage/JsonAdaptedAssignment.java 0.00% 2 Missing ⚠️
...in/java/seedu/address/commons/util/StringUtil.java 80.00% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ Complexity Δ
...address/logic/commands/GradeAssignmentCommand.java 80.95% <ø> (ø) 11.00 <0.00> (ø)
...dress/logic/parser/AddAssignmentCommandParser.java 93.75% <100.00%> (+0.41%) 3.00 <0.00> (ø)
...ava/seedu/address/model/assignment/Assignment.java 61.36% <100.00%> (ø) 11.00 <0.00> (ø)
...in/java/seedu/address/commons/util/StringUtil.java 91.66% <80.00%> (-3.08%) 8.00 <1.00> (+1.00) ⬇️
...a/seedu/address/storage/JsonAdaptedAssignment.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...in/java/seedu/address/logic/parser/ParserUtil.java 90.19% <55.55%> (+3.98%) 19.00 <0.00> (+2.00)

@lm-44 lm-44 linked an issue Oct 21, 2024 that may be closed by this pull request
Copy link

@avrilmohh avrilmohh left a comment

Choose a reason for hiding this comment

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

Overall looks good!

Comment on lines +79 to +85
try {
int value = Integer.parseInt(s);
// "-0" and "+0" is successfully parsed by Integer#parseInt(String)
return value >= 0 && !s.startsWith("+") && !s.startsWith("-");
} catch (NumberFormatException nfe) {
return false;
}

Choose a reason for hiding this comment

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

Good job on ensuring the input is a valid unsigned integer and not a signed one.

@lm-44 lm-44 modified the milestones: v1.4, v1.5 Oct 23, 2024
Copy link

@jian7490 jian7490 left a comment

Choose a reason for hiding this comment

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

LGTM!

throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
AddAssignmentCommand.MESSAGE_USAGE), pe);
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddAssignmentCommand.MESSAGE_USAGE), pe);

Choose a reason for hiding this comment

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

Good formatting to follow coding standard

Comment on lines -121 to +125
int parsedScore;
try {
parsedScore = Integer.parseInt(trimmedMaxScore);
} catch (NumberFormatException e) {
throw new ParseException("The score must be an integer!");
if (!StringUtil.isUnsignedInteger(trimmedMaxScore)) {
throw new ParseException(Assignment.MAX_SCORE_MESSAGE_CONSTRAINTS);
}
return parsedScore;
return Integer.parseInt(trimmedMaxScore);

Choose a reason for hiding this comment

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

This is a similar issue happening in gradeAssignmentCommand. Great attempt to simplify the code.

@lm-44 lm-44 removed a link to an issue Oct 28, 2024
@lm-44 lm-44 merged commit 93f67e3 into AY2425S1-CS2103-F11-1:master Oct 28, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity.High A flaw that affects most users and causes major problems for users type.Bug A bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix negative max score bug for add assignment command
3 participants