lizard 1.22.0__tar.gz → 1.22.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. {lizard-1.22.0 → lizard-1.22.2}/PKG-INFO +1 -1
  2. {lizard-1.22.0 → lizard-1.22.2}/lizard.egg-info/PKG-INFO +1 -1
  3. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardduplicate.py +33 -1
  4. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/version.py +1 -1
  5. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/erlang.py +1 -1
  6. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/gdscript.py +1 -1
  7. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/kotlin.py +1 -1
  8. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/perl.py +2 -2
  9. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/php.py +1 -1
  10. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/python.py +1 -1
  11. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/rubylike.py +1 -1
  12. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/rust.py +1 -1
  13. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/scala.py +1 -1
  14. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/solidity.py +1 -1
  15. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/swift.py +1 -1
  16. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/typescript.py +7 -0
  17. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/zig.py +1 -1
  18. {lizard-1.22.0 → lizard-1.22.2}/LICENSE.txt +0 -0
  19. {lizard-1.22.0 → lizard-1.22.2}/README.rst +0 -0
  20. {lizard-1.22.0 → lizard-1.22.2}/lizard.egg-info/SOURCES.txt +0 -0
  21. {lizard-1.22.0 → lizard-1.22.2}/lizard.egg-info/dependency_links.txt +0 -0
  22. {lizard-1.22.0 → lizard-1.22.2}/lizard.egg-info/entry_points.txt +0 -0
  23. {lizard-1.22.0 → lizard-1.22.2}/lizard.egg-info/requires.txt +0 -0
  24. {lizard-1.22.0 → lizard-1.22.2}/lizard.egg-info/top_level.txt +0 -0
  25. {lizard-1.22.0 → lizard-1.22.2}/lizard.py +0 -0
  26. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/__init__.py +0 -0
  27. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/auto_open.py +0 -0
  28. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/checkstyleoutput.py +0 -0
  29. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/csvoutput.py +0 -0
  30. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/default_ordered_dict.py +0 -0
  31. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/extension_base.py +0 -0
  32. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/htmloutput.py +0 -0
  33. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/keywords.py +0 -0
  34. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardboolcount.py +0 -0
  35. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardcomplextags.py +0 -0
  36. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardcpre.py +0 -0
  37. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizarddependencycount.py +0 -0
  38. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizarddumpcomments.py +0 -0
  39. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardduplicated_param_list.py +0 -0
  40. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardexitcount.py +0 -0
  41. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardgotocount.py +0 -0
  42. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardignoreassert.py +0 -0
  43. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardio.py +0 -0
  44. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardmccabe.py +0 -0
  45. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardmodified.py +0 -0
  46. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardnd.py +0 -0
  47. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardnonstrict.py +0 -0
  48. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardns.py +0 -0
  49. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardoutside.py +0 -0
  50. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardstatementcount.py +0 -0
  51. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/lizardwordcount.py +0 -0
  52. {lizard-1.22.0 → lizard-1.22.2}/lizard_ext/xmloutput.py +0 -0
  53. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/__init__.py +0 -0
  54. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/clike.py +0 -0
  55. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/code_reader.py +0 -0
  56. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/csharp.py +0 -0
  57. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/fortran.py +0 -0
  58. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/go.py +0 -0
  59. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/golike.py +0 -0
  60. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/java.py +0 -0
  61. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/javascript.py +0 -0
  62. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/js_style_regex_expression.py +0 -0
  63. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/lua.py +0 -0
  64. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/objc.py +0 -0
  65. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/plsql.py +0 -0
  66. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/r.py +0 -0
  67. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/ruby.py +0 -0
  68. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/script_language.py +0 -0
  69. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/st.py +0 -0
  70. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/tnsdl.py +0 -0
  71. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/tsx.py +0 -0
  72. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/ttcn.py +0 -0
  73. {lizard-1.22.0 → lizard-1.22.2}/lizard_languages/vue.py +0 -0
  74. {lizard-1.22.0 → lizard-1.22.2}/setup.cfg +0 -0
  75. {lizard-1.22.0 → lizard-1.22.2}/setup.py +0 -0
  76. {lizard-1.22.0 → lizard-1.22.2}/test/testApplication.py +0 -0
  77. {lizard-1.22.0 → lizard-1.22.2}/test/testAssertionExtension.py +0 -0
  78. {lizard-1.22.0 → lizard-1.22.2}/test/testBasicFunctionInfo.py +0 -0
  79. {lizard-1.22.0 → lizard-1.22.2}/test/testCOutsideComplexity.py +0 -0
  80. {lizard-1.22.0 → lizard-1.22.2}/test/testCPreprocessorExtension.py +0 -0
  81. {lizard-1.22.0 → lizard-1.22.2}/test/testCommentOptions.py +0 -0
  82. {lizard-1.22.0 → lizard-1.22.2}/test/testCyclomaticComplexity.py +0 -0
  83. {lizard-1.22.0 → lizard-1.22.2}/test/testExtension.py +0 -0
  84. {lizard-1.22.0 → lizard-1.22.2}/test/testFilesFilter.py +0 -0
  85. {lizard-1.22.0 → lizard-1.22.2}/test/testFunctionDependencyCount.py +0 -0
  86. {lizard-1.22.0 → lizard-1.22.2}/test/testFunctionExitCount.py +0 -0
  87. {lizard-1.22.0 → lizard-1.22.2}/test/testFunctionGotoCount.py +0 -0
  88. {lizard-1.22.0 → lizard-1.22.2}/test/testFunctionStatementCount.py +0 -0
  89. {lizard-1.22.0 → lizard-1.22.2}/test/testHelpers.py +0 -0
  90. {lizard-1.22.0 → lizard-1.22.2}/test/testLanguages.py +0 -0
  91. {lizard-1.22.0 → lizard-1.22.2}/test/testMcCabe.py +0 -0
  92. {lizard-1.22.0 → lizard-1.22.2}/test/testNestedStructures.py +0 -0
  93. {lizard-1.22.0 → lizard-1.22.2}/test/testNestingDepth.py +0 -0
  94. {lizard-1.22.0 → lizard-1.22.2}/test/testOutput.py +0 -0
  95. {lizard-1.22.0 → lizard-1.22.2}/test/testOutputCSV.py +0 -0
  96. {lizard-1.22.0 → lizard-1.22.2}/test/testOutputFile.py +0 -0
  97. {lizard-1.22.0 → lizard-1.22.2}/test/testOutputHTML.py +0 -0
  98. {lizard-1.22.0 → lizard-1.22.2}/test/testTokenizer.py +0 -0
  99. {lizard-1.22.0 → lizard-1.22.2}/test/test_analyzer.py +0 -0
  100. {lizard-1.22.0 → lizard-1.22.2}/test/test_auto_open.py +0 -0
  101. {lizard-1.22.0 → lizard-1.22.2}/test/test_options.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lizard
3
- Version: 1.22.0
3
+ Version: 1.22.2
4
4
  Summary: A code analyzer without caring the C/C++ header files. It works with Java, C/C++, JavaScript, Python, Ruby, Swift, Objective C. Metrics includes cyclomatic complexity number etc.
5
5
  Home-page: http://www.lizard.ws
6
6
  Download-URL: https://pypi.python.org/lizard/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lizard
3
- Version: 1.22.0
3
+ Version: 1.22.2
4
4
  Summary: A code analyzer without caring the C/C++ header files. It works with Java, C/C++, JavaScript, Python, Ruby, Swift, Objective C. Metrics includes cyclomatic complexity number etc.
5
5
  Home-page: http://www.lizard.ws
6
6
  Download-URL: https://pypi.python.org/lizard/
@@ -2,6 +2,7 @@
2
2
  Get Duplicated parameter lists
3
3
  '''
4
4
  from __future__ import print_function
5
+ from bisect import bisect_right
5
6
  from collections import deque
6
7
  from itertools import groupby
7
8
  from .default_ordered_dict import DefaultOrderedDict
@@ -98,6 +99,8 @@ class DuplicateFinder(object):
98
99
  self.duplicate_token_count = 0
99
100
  self.nodes = nodes
100
101
  self.boundaries = set(boundaries + [len(nodes)])
102
+ self.sorted_boundaries = sorted(self.boundaries)
103
+ self.covered_duplicates = DefaultOrderedDict(list)
101
104
  self.hashed_node_indice = DefaultOrderedDict(list)
102
105
  for i, node_hash in enumerate(n.hash for n in nodes):
103
106
  if i in self.boundaries:
@@ -117,8 +120,37 @@ class DuplicateFinder(object):
117
120
  token_count = len(dup) * \
118
121
  (dup[0][1] - dup[0][0] + self.sample_size)
119
122
  if token_count >= self.min_duplicate_tokens:
120
- self.duplicate_token_count += token_count
123
+ self._add_duplicate_ranges(dup)
121
124
  yield dup
125
+ self.duplicate_token_count = sum(
126
+ self._merged_token_count(intervals)
127
+ for intervals in self.covered_duplicates.values())
128
+
129
+ def _add_duplicate_ranges(self, dup):
130
+ for start, end in dup:
131
+ boundary_index = self._boundary_index(start)
132
+ boundary_start = self.sorted_boundaries[boundary_index]
133
+ self.covered_duplicates[boundary_index].append(
134
+ (start - boundary_start,
135
+ end - boundary_start + self.sample_size))
136
+
137
+ def _boundary_index(self, index):
138
+ return bisect_right(self.sorted_boundaries, index) - 1
139
+
140
+ @staticmethod
141
+ def _merged_token_count(intervals):
142
+ if not intervals:
143
+ return 0
144
+ intervals = sorted(intervals)
145
+ start, end = intervals[0]
146
+ token_count = 0
147
+ for current_start, current_end in intervals[1:]:
148
+ if current_start <= end:
149
+ end = max(end, current_end)
150
+ else:
151
+ token_count += end - start
152
+ start, end = current_start, current_end
153
+ return token_count + end - start
122
154
 
123
155
  def duplicate_rate(self):
124
156
  try:
@@ -3,4 +3,4 @@
3
3
  #
4
4
  # pylint: disable=missing-docstring,invalid-name
5
5
 
6
- version = "1.22.0"
6
+ version = "1.22.2"
@@ -13,7 +13,7 @@ class ErlangReader(CodeReader):
13
13
 
14
14
  ext = ['erl', 'hrl', 'es', 'escript']
15
15
  language_names = ['erlang']
16
-
16
+
17
17
  # Separated condition categories
18
18
  _control_flow_keywords = {'if', 'catch', 'when'} # when is used in guards
19
19
  _logical_operators = {'and', 'or', 'not'}
@@ -9,7 +9,7 @@ class GDScriptReader(PythonReader):
9
9
 
10
10
  ext = ['gd']
11
11
  language_names = ['GDScript']
12
-
12
+
13
13
  # Separated condition categories
14
14
  _control_flow_keywords = {'if', 'elif', 'for', 'while', 'catch', 'do'}
15
15
  _logical_operators = {'&&', '||'}
@@ -13,7 +13,7 @@ class KotlinReader(CodeReader, CCppCommentsMixin, SwiftReplaceLabel):
13
13
 
14
14
  ext = ['kt', 'kts']
15
15
  language_names = ['kotlin']
16
-
16
+
17
17
  # Separated condition categories
18
18
  _control_flow_keywords = {'if', 'for', 'while', 'catch'}
19
19
  _logical_operators = {'&&', '||'}
@@ -19,9 +19,9 @@ class PerlReader(CodeReader, ScriptLanguageMixIn):
19
19
 
20
20
  ext = ['pl', 'pm']
21
21
  language_names = ['perl']
22
-
22
+
23
23
  # Separated condition categories
24
- _control_flow_keywords = {'if', 'elsif', 'unless', 'while', 'until', 'for',
24
+ _control_flow_keywords = {'if', 'elsif', 'unless', 'while', 'until', 'for',
25
25
  'foreach', 'when', 'given', 'default', 'do'}
26
26
  _logical_operators = {'&&', '||'} # Perl also has 'and', 'or' with different precedence
27
27
  _case_keywords = set()
@@ -242,7 +242,7 @@ class PHPReader(CodeReader, CCppCommentsMixin):
242
242
 
243
243
  ext = ['php']
244
244
  language_names = ['php']
245
-
245
+
246
246
  # Separated condition categories
247
247
  _control_flow_keywords = {'if', 'elseif', 'for', 'foreach', 'while', 'catch', 'match'}
248
248
  _logical_operators = {'&&', '||'} # PHP also has 'and', 'or' with different precedence
@@ -29,7 +29,7 @@ class PythonReader(CodeReader, ScriptLanguageMixIn):
29
29
 
30
30
  ext = ['py']
31
31
  language_names = ['python']
32
-
32
+
33
33
  # Separated condition categories
34
34
  _control_flow_keywords = {'if', 'elif', 'for', 'while', 'except', 'finally'}
35
35
  _logical_operators = {'and', 'or'}
@@ -98,7 +98,7 @@ class RubylikeReader(CodeReader, ScriptLanguageMixIn):
98
98
  # pylint: disable=R0903
99
99
 
100
100
  # Separated condition categories
101
- _control_flow_keywords = {'if', 'elsif', 'elseif', 'until', 'for', 'while',
101
+ _control_flow_keywords = {'if', 'elsif', 'elseif', 'until', 'for', 'while',
102
102
  'rescue', 'ensure', 'when'}
103
103
  _logical_operators = {'and', 'or', '||', '&&'} # Both word and symbol forms
104
104
  _case_keywords = set() # Ruby uses 'when' for case expressions
@@ -12,7 +12,7 @@ class RustReader(CodeReader, CCppCommentsMixin):
12
12
 
13
13
  ext = ['rs']
14
14
  language_names = ['rust']
15
-
15
+
16
16
  # Separated condition categories
17
17
  _control_flow_keywords = {'if', 'for', 'while', 'catch', 'match', 'where'}
18
18
  _logical_operators = {'&&', '||'}
@@ -12,7 +12,7 @@ class ScalaReader(CodeReader, CCppCommentsMixin):
12
12
 
13
13
  ext = ['scala']
14
14
  language_names = ['scala']
15
-
15
+
16
16
  # Separated condition categories
17
17
  _control_flow_keywords = {'if', 'for', 'while', 'catch', 'do'}
18
18
  _logical_operators = {'&&', '||'}
@@ -11,7 +11,7 @@ class SolidityReader(CodeReader, CCppCommentsMixin):
11
11
 
12
12
  ext = ['sol']
13
13
  language_names = ['solidity']
14
-
14
+
15
15
  # Separated condition categories
16
16
  _control_flow_keywords = {'if', 'for', 'while'}
17
17
  _logical_operators = {'&&', '||'}
@@ -30,7 +30,7 @@ class SwiftReader(CodeReader, CCppCommentsMixin, SwiftReplaceLabel):
30
30
  FUNC_KEYWORD = 'def'
31
31
  ext = ['swift']
32
32
  language_names = ['swift']
33
-
33
+
34
34
  # Separated condition categories
35
35
  _control_flow_keywords = {'if', 'for', 'while', 'catch', 'guard'}
36
36
  _logical_operators = {'&&', '||'}
@@ -98,6 +98,11 @@ class TypeScriptReader(CodeReader, CCppCommentsMixin):
98
98
  elif content[i] == '}':
99
99
  brace_count -= 1
100
100
  i += 1
101
+
102
+ if brace_count > 0:
103
+ yield token
104
+ return
105
+
101
106
  expr = content[expr_start:i - 1]
102
107
  yield expr
103
108
  yield '}'
@@ -334,6 +339,8 @@ class TypeScriptStates(CodeStateMachine):
334
339
  self._prev_token = token
335
340
  return
336
341
  if token == 'function':
342
+ if self.started_function and not self.as_object:
343
+ self._pop_function_from_stack()
337
344
  self._state = self._function
338
345
  elif token in ('if', 'switch', 'for', 'while', 'catch'):
339
346
  self.next(self._expecting_condition_and_statement_block)
@@ -12,7 +12,7 @@ from .golike import GoLikeStates
12
12
  class ZigReader(CodeReader, CCppCommentsMixin):
13
13
  ext = ["zig"]
14
14
  language_names = ["zig"]
15
-
15
+
16
16
  # Separated condition categories
17
17
  _control_flow_keywords = {"if", "for", "while", "try", "catch"}
18
18
  _logical_operators = {"and", "or", "orelse"} # orelse is Zig's null coalescing
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes