Skip to content

Commit 5364cab

Browse files
authored
Merge pull request #21 from opatrascoiu/main
Fix Deep Source issues
2 parents 240bc3a + 5cafaae commit 5364cab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+432
-304
lines changed

.deepsource.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version = 1
2+
3+
[[analyzers]]
4+
name = "python"
5+
enabled = true
6+
7+
[analyzers.meta]
8+
runtime_version = "3.x.x"

src/jdmn/feel/lib/BaseFEELLib.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -965,13 +965,15 @@ def functionNotEqual(self, function1: Any, function2: Any) -> BOOLEAN:
965965
#
966966
# Conversion functions
967967
#
968-
def asList(self, *args) -> LIST:
968+
@staticmethod
969+
def asList(*args) -> LIST:
969970
if len(args) == 0:
970971
return []
971972
else:
972973
return list(args)
973974

974-
def asElement(self, list_: LIST) -> Any:
975+
@staticmethod
976+
def asElement(list_: LIST) -> Any:
975977
if list_ is None:
976978
return None
977979
elif len(list_) == 1:
@@ -998,9 +1000,10 @@ def rangeToListWithArgs(self, isOpenStart: bool, start: DECIMAL, isOpenEnd: bool
9981000
return []
9991001
else:
10001002
range_ = self.intRange(isOpenStart, start, isOpenEnd, end)
1001-
return [x for x in range_]
1003+
return list(range_)
10021004

1003-
def intRange(self, isOpenStart: bool, start: DECIMAL, isOpenEnd: bool, end: DECIMAL):
1005+
@staticmethod
1006+
def intRange(isOpenStart: bool, start: DECIMAL, isOpenEnd: bool, end: DECIMAL):
10041007
if start is None or end is None:
10051008
return None
10061009

@@ -1011,7 +1014,8 @@ def intRange(self, isOpenStart: bool, start: DECIMAL, isOpenEnd: bool, end: DECI
10111014
else:
10121015
return range(startValue, endValue - 1, -1)
10131016

1014-
def flattenFirstLevel(self, list_: LIST) -> LIST:
1017+
@staticmethod
1018+
def flattenFirstLevel(list_: LIST) -> LIST:
10151019
if list_ is None:
10161020
return None
10171021

@@ -1024,21 +1028,23 @@ def flattenFirstLevel(self, list_: LIST) -> LIST:
10241028

10251029
return result
10261030

1027-
def elementAt(self, list: LIST, number: DECIMAL) -> Any:
1028-
if list is None:
1031+
@staticmethod
1032+
def elementAt(list_: LIST, number: DECIMAL) -> Any:
1033+
if list_ is None:
10291034
return None
10301035

10311036
index = int(number)
10321037

1033-
listSize = len(list)
1034-
if 1 <= index and index <= listSize:
1035-
return list[index - 1]
1036-
elif -listSize <= index and index <= -1:
1037-
return list[listSize + index]
1038+
listSize = len(list_)
1039+
if 1 <= index <= listSize:
1040+
return list_[index - 1]
1041+
elif -listSize <= index <= -1:
1042+
return list_[listSize + index]
10381043
else:
10391044
return None
10401045

1041-
def ruleMatches(self, eventListener: EventListener, rule: Rule, *operands) -> bool:
1046+
@staticmethod
1047+
def ruleMatches(eventListener: EventListener, rule: Rule, *operands) -> bool:
10421048
if (operands is None or len(operands) == 0):
10431049
return False
10441050
else:
@@ -1054,7 +1060,7 @@ def ruleMatches(self, eventListener: EventListener, rule: Rule, *operands) -> bo
10541060
return True
10551061

10561062
def valueOf(self, number: int) -> DECIMAL:
1057-
pass
1063+
raise NotImplementedError()
10581064

10591065
def intValue(self, number: DECIMAL) -> int:
1060-
pass
1066+
raise NotImplementedError()

src/jdmn/feel/lib/BaseStandardFEELLib.py

+42-42
Original file line numberDiff line numberDiff line change
@@ -349,19 +349,19 @@ def substringAfter(self, string: STRING, match: STRING) -> STRING:
349349
self.logError(message, e)
350350
return None
351351

352-
def replace(self, input: STRING, pattern: STRING, replacement: STRING, flags: STRING = "") -> STRING:
352+
def replace(self, input_: STRING, pattern: STRING, replacement: STRING, flags: STRING = "") -> STRING:
353353
try:
354-
return self.stringLib.replace(input, pattern, replacement, flags)
354+
return self.stringLib.replace(input_, pattern, replacement, flags)
355355
except Exception as e:
356-
message: STRING = "replace({}, {}, {}, {})".format(input, pattern, replacement, flags)
356+
message: STRING = "replace({}, {}, {}, {})".format(input_, pattern, replacement, flags)
357357
self.logError(message, e)
358358
return None
359359

360-
def matches(self, input: STRING, pattern: STRING, flags: STRING = "") -> BOOLEAN:
360+
def matches(self, input_: STRING, pattern: STRING, flags: STRING = "") -> BOOLEAN:
361361
try:
362-
return self.stringLib.matches(input, pattern, flags)
362+
return self.stringLib.matches(input_, pattern, flags)
363363
except Exception as e:
364-
message: STRING = "matches({}, {}, {})".format(input, pattern, flags)
364+
message: STRING = "matches({}, {}, {})".format(input_, pattern, flags)
365365
self.logError(message, e)
366366
return None
367367

@@ -626,27 +626,27 @@ def monthOfYear(self, date: DATE) -> STRING:
626626
# List functions
627627
#
628628

629-
def listContains(self, list: LIST, element: Any) -> BOOLEAN:
629+
def listContains(self, list_: LIST, element: Any) -> BOOLEAN:
630630
try:
631-
return self.listLib.listContains(list, element)
631+
return self.listLib.listContains(list_, element)
632632
except Exception as e:
633-
message: STRING = "listContains({}, {})".format(list, element)
633+
message: STRING = "listContains({}, {})".format(list_, element)
634634
self.logError(message, e)
635635
return None
636636

637-
def append(self, list: LIST, *items):
637+
def append(self, list_: LIST, *items):
638638
try:
639-
return self.listLib.append(list, *items)
639+
return self.listLib.append(list_, *items)
640640
except Exception as e:
641-
message: STRING = "append({}, {})".format(list, *items)
641+
message: STRING = "append({}, {})".format(list_, *items)
642642
self.logError(message, e)
643643
return None
644644

645-
def count(self, list: LIST) -> DECIMAL:
645+
def count(self, list_: LIST) -> DECIMAL:
646646
try:
647-
return self.numberLib.count(list)
647+
return self.numberLib.count(list_)
648648
except Exception as e:
649-
message = "count({})".format(list)
649+
message = "count({})".format(list_)
650650
self.logError(message, e)
651651
return None
652652

@@ -674,11 +674,11 @@ def sum(self, *args) -> Optional[comparable]:
674674
self.logError(message, e)
675675
return None
676676

677-
def sublist(self, list: LIST, startPosition: DECIMAL, length: DECIMAL = None) -> LIST:
677+
def sublist(self, list_: LIST, startPosition: DECIMAL, length: DECIMAL = None) -> LIST:
678678
try:
679-
return self.listLib.sublist(list, self.intValue(startPosition), self.intValue(length))
679+
return self.listLib.sublist(list_, self.intValue(startPosition), self.intValue(length))
680680
except Exception as e:
681-
message: STRING = "sublist({}, {}, {})".format(list, startPosition, length)
681+
message: STRING = "sublist({}, {}, {})".format(list_, startPosition, length)
682682
self.logError(message, e)
683683
return None
684684

@@ -690,34 +690,34 @@ def concatenate(self, *lists) -> LIST:
690690
self.logError(message, e)
691691
return None
692692

693-
def insertBefore(self, list: LIST, position: DECIMAL, newItem: Any) -> LIST:
693+
def insertBefore(self, list_: LIST, position: DECIMAL, newItem: Any) -> LIST:
694694
try:
695-
return self.listLib.insertBefore(list, self.intValue(position), newItem)
695+
return self.listLib.insertBefore(list_, self.intValue(position), newItem)
696696
except Exception as e:
697-
message: STRING = "insertBefore({}, {}, {})".format(list, position, newItem)
697+
message: STRING = "insertBefore({}, {}, {})".format(list_, position, newItem)
698698
self.logError(message, e)
699699
return None
700700

701-
def remove(self, list: LIST, position: Any):
701+
def remove(self, list_: LIST, position: Any):
702702
try:
703-
return self.listLib.remove(list, self.intValue(position))
703+
return self.listLib.remove(list_, self.intValue(position))
704704
except Exception as e:
705-
message: STRING = "remove({})".format(list)
705+
message: STRING = "remove({})".format(list_)
706706
self.logError(message, e)
707707
return None
708708

709-
def reverse(self, list: LIST) -> LIST:
709+
def reverse(self, list_: LIST) -> LIST:
710710
try:
711-
return self.listLib.reverse(list)
711+
return self.listLib.reverse(list_)
712712
except Exception as e:
713-
message: STRING = "reverse({})".format(list)
713+
message: STRING = "reverse({})".format(list_)
714714
self.logError(message, e)
715715
return None
716716

717-
def indexOf(self, list: LIST, match: Any) -> LIST:
717+
def indexOf(self, list_: LIST, match: Any) -> LIST:
718718
result = []
719-
if list is not None:
720-
for i, o in enumerate(list):
719+
if list_ is not None:
720+
for i, o in enumerate(list_):
721721
if o is None and match is None or o is not None and o == match:
722722
result.append(self.valueOf(i + 1))
723723
return result
@@ -730,19 +730,19 @@ def union(self, *lists):
730730
self.logError(message, e)
731731
return None
732732

733-
def distinctValues(self, list: LIST) -> LIST:
733+
def distinctValues(self, list_: LIST) -> LIST:
734734
try:
735-
return self.listLib.distinctValues(list)
735+
return self.listLib.distinctValues(list_)
736736
except Exception as e:
737-
message: STRING = "distinctValues({})".format(list)
737+
message: STRING = "distinctValues({})".format(list_)
738738
self.logError(message, e)
739739
return None
740740

741-
def flatten(self, list: LIST) -> LIST:
741+
def flatten(self, list_: LIST) -> LIST:
742742
try:
743-
return self.listLib.flatten(list)
743+
return self.listLib.flatten(list_)
744744
except Exception as e:
745-
message: STRING = "flatten({})".format(list)
745+
message: STRING = "flatten({})".format(list_)
746746
self.logError(message, e)
747747
return None
748748

@@ -778,18 +778,18 @@ def mode(self, *args) -> LIST:
778778
self.logError(message, e)
779779
return None
780780

781-
def collect(self, result: LIST, list: LIST) -> None:
781+
def collect(self, result: LIST, list_: LIST) -> None:
782782
try:
783-
self.listLib.collect(result, list)
783+
self.listLib.collect(result, list_)
784784
except Exception as e:
785-
message: STRING = "collect({}, {})".format(result, list)
785+
message: STRING = "collect({}, {})".format(result, list_)
786786
self.logError(message, e)
787787

788-
def sort(self, list: LIST, precedes: LambdaExpression) -> LIST:
788+
def sort(self, list_: LIST, precedes: LambdaExpression) -> LIST:
789789
try:
790-
return self.listLib.sort(list, precedes)
790+
return self.listLib.sort(list_, precedes)
791791
except Exception as e:
792-
message: STRING = "sort({})".format(list)
792+
message: STRING = "sort({})".format(list_)
793793
self.logError(message, e)
794794
return None
795795

src/jdmn/feel/lib/DefaultStandardFEELLib.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ def __init__(self):
2323
#
2424
# Extra conversion functions
2525
#
26-
def valueOf(self, number: INTEGER) -> DECIMAL:
26+
@staticmethod
27+
def valueOf(number: INTEGER) -> DECIMAL:
2728
if number is None:
2829
return None
2930
else:
3031
return Decimal(number)
3132

32-
def intValue(self, number: DECIMAL) -> INTEGER:
33+
@staticmethod
34+
def intValue(number: DECIMAL) -> INTEGER:
3335
if number is None:
3436
return None
3537
else:

src/jdmn/feel/lib/FEELLib.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@ def logError(self, message: str, e: Exception = None) -> None:
2525
else:
2626
self.LOGGER.exception(message)
2727

28-
def toDate(self, from_: Any) -> DATE:
28+
@staticmethod
29+
def toDate(from_: Any) -> DATE:
2930
raise Exception("Not supported yet")
3031

31-
def toTime(self, from_: Any) -> TIME:
32+
@staticmethod
33+
def toTime(from_: Any) -> TIME:
3234
raise Exception("Not supported yet")
3335

34-
def toDateTime(self, from_: Any) -> DATE_TIME:
36+
@staticmethod
37+
def toDateTime(from_: Any) -> DATE_TIME:
3538
raise Exception("Not supported yet")
3639

3740
#
3841
# Error conversions
3942
#
40-
def toNull(self, obj: Any) -> Any:
43+
@staticmethod
44+
def toNull(obj: Any) -> Any:
4145
return None

src/jdmn/feel/lib/type/ComparableComparator.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020

2121

2222
class ComparableComparator(RelationalComparator):
23-
def __init__(self):
24-
super().__init__()
25-
2623
def compare(self, first: comparable, second: comparable) -> int:
2724
return self.compareTo(first, second)
2825

@@ -31,16 +28,16 @@ def equalTo(self, first: comparable, second: comparable) -> BOOLEAN:
3128
lambda: True,
3229
lambda: False,
3330
lambda: False,
34-
lambda: type(first) == type(second) and self.compareTo(first, second) == 0
31+
lambda: type(first) is type(second) and self.compareTo(first, second) == 0
3532
])
3633

3734
def lessThan(self, first: comparable, second: comparable) -> BOOLEAN:
3835
return self.applyOperator(first, second, [
3936
lambda: None,
4037
lambda: None,
4138
lambda: None,
42-
lambda: type(first) == type(second) and self.compareTo(first, second) < 0
39+
lambda: type(first) is type(second) and self.compareTo(first, second) < 0
4340
])
4441

4542
def compareTo(self, first: comparable, second: comparable) -> int:
46-
pass
43+
raise NotImplementedError()

src/jdmn/feel/lib/type/EqualityComparator.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616

1717

1818
class EqualityComparator:
19-
def __init__(self):
20-
pass
21-
2219
def equalTo(self, first: Any, second: Any) -> Optional[bool]:
23-
pass
20+
raise NotImplementedError()
2421

2522
def notEqualTo(self, first: Any, second: Any) -> Optional[bool]:
2623
return TernaryBooleanLogicUtil().not_(self.equalTo(first, second))

src/jdmn/feel/lib/type/RelationalComparator.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@
1717

1818

1919
class RelationalComparator(EqualityComparator):
20-
def __init__(self):
21-
super().__init__()
22-
2320
def compare(self, first: Any, second: Any) -> int:
24-
pass
21+
raise NotImplementedError()
2522

2623
def lessThan(self, first: Any, second: Any) -> Optional[bool]:
27-
pass
24+
raise NotImplementedError()
2825

2926
def greaterThan(self, first: Any, second: Any) -> Optional[bool]:
3027
return self.lessThan(second, first)

src/jdmn/feel/lib/type/bool/DefaultBooleanLib.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717

1818
class DefaultBooleanLib:
19-
def all(self, *args) -> Optional[bool]:
19+
@staticmethod
20+
def all(*args) -> Optional[bool]:
2021
operands = varArgToList(*args)
2122

2223
oneFalse = False
@@ -33,7 +34,8 @@ def all(self, *args) -> Optional[bool]:
3334
else:
3435
return None
3536

36-
def any(self, *args) -> Optional[bool]:
37+
@staticmethod
38+
def any(*args) -> Optional[bool]:
3739
operands = varArgToList(*args)
3840

3941
oneTrue = False

0 commit comments

Comments
 (0)