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 long numbers problem #98

Merged
merged 2 commits into from
Jun 3, 2023
Merged

Fix long numbers problem #98

merged 2 commits into from
Jun 3, 2023

Conversation

geirolz
Copy link
Owner

@geirolz geirolz commented Jun 3, 2023

No description provided.

@geirolz geirolz self-assigned this Jun 3, 2023
@geirolz geirolz force-pushed the fix_long_numbers_problem branch from 5b9a56d to 8331b94 Compare June 3, 2023 12:57
@geirolz geirolz merged commit 3c4b930 into main Jun 3, 2023
@geirolz geirolz deleted the fix_long_numbers_problem branch June 3, 2023 12:58
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Scalastyle (reported by Codacy) found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

case bd if bd.isValidLong => ofLong(bd.toLongExact)
case db if db.isDecimalFloat => ofFloat(db.floatValue)
case db if db.isDecimalDouble => ofDouble(db.doubleValue)
case bd => ofBigDecimal(bd)
case bd =>

Check notice

Code scanning / Codacy-scalameta-pro (reported by Codacy)

Prohibit case statement pattern match from being lowercase.

Lower case pattern matching.
case db if db.isValidByte => ofLong(db.toByteExact.toLong)
case db if db.isValidShort => ofLong(db.toShortExact.toLong)
case db if db.isValidInt => ofLong(db.toIntExact.toLong)
case db if db.isValidByte => ofByte(db.toByteExact)

Check notice

Code scanning / Codacy-scalameta-pro (reported by Codacy)

Prohibits same expression on cases inside the same scope

Duplicated case statements
testFromDataString[BigDecimal]
testFromDataString[VeryLongNumericString]

private def testFromNumberString[T: Arbitrary](shouldFail: Boolean = false)(implicit

Check notice

Code scanning / Codacy-scalameta-pro (reported by Codacy)

Values should have minimum scope to avoid misuses.

testFromNumberString should have a smaller scope by using private[this]
property(s"Xml.fromNumberString works with ${c.runtimeClass.getSimpleName}") {
forAll { (value: T) =>
assertEquals(
Xml.fromNumberString(value.toString).get.toBigDecimal,

Check notice

Code scanning / Codacy-scalameta-pro (reported by Codacy)

Calling get should be avoided on Option and Either.

Usage of get on optional type.
number.toBigDecimal,
Some(BigDecimal(value.toString))
)
case other =>

Check notice

Code scanning / Codacy-scalameta-pro (reported by Codacy)

Prohibit case statement pattern match from being lowercase.

Lower case pattern matching.
}
}

private def testFromDataString[T: Arbitrary](implicit

Check notice

Code scanning / Codacy-scalameta-pro (reported by Codacy)

Values should have minimum scope to avoid misuses.

testFromDataString should have a smaller scope by using private[this]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant