Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit d42ef22

Browse files
committed
chore: Sonar fixes
1 parent 6015a19 commit d42ef22

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Diff for: timefold-solver-python-core/src/main/java/ai/timefold/solver/python/score/constraint/ConstraintRefPythonJavaTypeMapping.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public PythonLikeObject toPythonObject(ConstraintRef javaObject) {
5050
@Override
5151
public ConstraintRef toJavaObject(PythonLikeObject pythonObject) {
5252
try {
53-
var packageName = ((PythonString) packageNameField.get(pythonObject)).value.toString();
54-
var constraintName = ((PythonString) constraintNameField.get(pythonObject)).value.toString();
53+
var packageName = ((PythonString) packageNameField.get(pythonObject)).value;
54+
var constraintName = ((PythonString) constraintNameField.get(pythonObject)).value;
5555
return ConstraintRef.of(packageName, constraintName);
5656
} catch (IllegalAccessException e) {
5757
throw new RuntimeException(e);

Diff for: timefold-solver-python-core/src/main/python/score/_score_analysis.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def constraint_id(self) -> str:
5757
@staticmethod
5858
def parse_id(constraint_id: str):
5959
slash_index = constraint_id.rfind('/')
60-
if slash_index == -1: raise RuntimeError(
61-
f'The constraint_id {constraint_id} is invalid as it does not contain a package separator \'/\'.')
60+
if slash_index == -1:
61+
raise IndexError(
62+
f'The constraint_id {constraint_id} is invalid as it does not contain a package separator \'/\'.')
6263
package_name = constraint_id[:slash_index]
6364
constraint_name = constraint_id[slash_index + 1:]
6465
return ConstraintRef(package_name, constraint_name)

0 commit comments

Comments
 (0)