lizard 1.17.21__py2.py3-none-any.whl → 1.17.23__py2.py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lizard
3
- Version: 1.17.21
3
+ Version: 1.17.23
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/
@@ -25,7 +25,7 @@ lizard_ext/lizardns.py,sha256=8pztUoRS_UWN24MawwxeHEJgYh49id5PWODUBb6O72U,4184
25
25
  lizard_ext/lizardoutside.py,sha256=FGm2tbBZ17-2OCgmQlD-vobUCfQKb0FAygf86eM3xuM,336
26
26
  lizard_ext/lizardstatementcount.py,sha256=xYk6ixSIItSE1BWQXzrWmduFgGhA3VR817SNKLffyVQ,1182
27
27
  lizard_ext/lizardwordcount.py,sha256=2QYXD7-AtkkgAbi9VSidunMbSsGQ7MKYb6IT-bS-cok,7575
28
- lizard_ext/version.py,sha256=3mpAZCQFxtZ-yEx47ZY238MZafb6rPxy9lZff5hymyA,182
28
+ lizard_ext/version.py,sha256=8OYSScMy6WgCedG7UcZmt7GxKDmCpya3NUQHG12M8_w,182
29
29
  lizard_ext/xmloutput.py,sha256=-cbh0he4O_X-wX56gkv9AnSPNN0qvR7FACqlBeezUS4,5609
30
30
  lizard_languages/__init__.py,sha256=ArNmUrVSU6HFxhDka1-vWMZpVIM39P-gqv6BoOLNMV8,1522
31
31
  lizard_languages/clike.py,sha256=INd5tkvwEVZm7dx2yHG2OIFHZn7JzQGmnT9WQNFZ2XU,11110
@@ -44,7 +44,7 @@ lizard_languages/jsx.py,sha256=DMagQSEvXZwy9AUj8B2l39PqgcAoZntAmEm67IKF7iM,8890
44
44
  lizard_languages/kotlin.py,sha256=v_o2orEzA5gB9vM_0h-E4QXjrc5Yum-0K6W6_laOThc,2844
45
45
  lizard_languages/lua.py,sha256=3nqBcunBzJrhv4Iqaf8xvbyqxZy3aSxJ-IiHimHFlac,1573
46
46
  lizard_languages/objc.py,sha256=2a1teLdaXZBtCeFiIZer1j_sVx9LZ1CbF2XfnqlvLmk,2319
47
- lizard_languages/perl.py,sha256=bSBolem2X6TjINz7pJGO_WhQxc-pAeiun0Q3RDeUOkY,3367
47
+ lizard_languages/perl.py,sha256=WUHuO9lIBRpL0fJKpAtEVsEatGMqzY2WymF8kSdPGRs,12143
48
48
  lizard_languages/php.py,sha256=8OufyR2TIWyf3bXuTmp37Vwf_tEPF4YV5M3i5_jnguA,1377
49
49
  lizard_languages/python.py,sha256=1e0dKbl82z-i_5dswkKaFIV5WuQDKztPHh9UNmSTLyE,3848
50
50
  lizard_languages/ruby.py,sha256=HL1ZckeuUUJU3QSVAOPsG_Zsl0C6X2PX5_VaWqclzkM,2277
@@ -60,9 +60,9 @@ lizard_languages/ttcn.py,sha256=ygjw_raBmPF-4mgoM8m6CAdyEMpTI-n1kZJK1RL4Vxo,2131
60
60
  lizard_languages/typescript.py,sha256=P_rphg5AXJAk9QetmvVKc2911ilPmiRa0Qa5fHWleJg,3829
61
61
  lizard_languages/vue.py,sha256=KXUBUo2R1zNF8Pffrz_KsQEN44m5XFRMoGXylxKUeT0,1038
62
62
  lizard_languages/zig.py,sha256=NX1iyBstBuJFeAGBOAIaRfrmeBREne2HX6Pt4fXZZTQ,586
63
- lizard-1.17.21.dist-info/LICENSE.txt,sha256=05ZjgQ8Cl1dD9p0BhW-Txzkc5rhCogGJVEuf1GT2Y_M,1303
64
- lizard-1.17.21.dist-info/METADATA,sha256=JSVKupJ-s_F1BqRK88FS30969tOc9TaHxPaPlZzXdzo,15753
65
- lizard-1.17.21.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
66
- lizard-1.17.21.dist-info/entry_points.txt,sha256=ZBqPhu-J3NoGGW5vn2Gfyoo0vdVlgBgM-wlNm0SGYUQ,39
67
- lizard-1.17.21.dist-info/top_level.txt,sha256=5NTrTaOLhHuTzXaGcZPKfuaOgUv7WafNGe0Zl5aycpg,35
68
- lizard-1.17.21.dist-info/RECORD,,
63
+ lizard-1.17.23.dist-info/LICENSE.txt,sha256=05ZjgQ8Cl1dD9p0BhW-Txzkc5rhCogGJVEuf1GT2Y_M,1303
64
+ lizard-1.17.23.dist-info/METADATA,sha256=RSP5Eq3wzytjP5T8yFmfWZaDaI9Xkd5iFCRg65yeGtE,15753
65
+ lizard-1.17.23.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
66
+ lizard-1.17.23.dist-info/entry_points.txt,sha256=ZBqPhu-J3NoGGW5vn2Gfyoo0vdVlgBgM-wlNm0SGYUQ,39
67
+ lizard-1.17.23.dist-info/top_level.txt,sha256=5NTrTaOLhHuTzXaGcZPKfuaOgUv7WafNGe0Zl5aycpg,35
68
+ lizard-1.17.23.dist-info/RECORD,,
lizard_ext/version.py CHANGED
@@ -3,4 +3,4 @@
3
3
  #
4
4
  # pylint: disable=missing-docstring,invalid-name
5
5
 
6
- version = "1.17.21"
6
+ version = "1.17.23"
lizard_languages/perl.py CHANGED
@@ -19,7 +19,7 @@ class PerlReader(CodeReader, ScriptLanguageMixIn):
19
19
 
20
20
  ext = ['pl', 'pm']
21
21
  language_names = ['perl']
22
- _conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach', '&&', '||', '?', 'when'])
22
+ _conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach', '&&', '||', '?', ':', 'when', 'given', 'default', 'do'])
23
23
 
24
24
  def __init__(self, context):
25
25
  super(PerlReader, self).__init__(context)
@@ -64,34 +64,157 @@ class PerlReader(CodeReader, ScriptLanguageMixIn):
64
64
 
65
65
 
66
66
  class PerlStates(CodeStateMachine):
67
- _conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach'])
67
+ _conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach', '&&', '||', '?', ':', 'when', 'given', 'default', 'do'])
68
68
 
69
69
  def __init__(self, context):
70
70
  super(PerlStates, self).__init__(context)
71
71
  self.function_name = ''
72
+ self.package_name = ''
73
+ self.variable_name = ''
72
74
  self.brace_count = 0
75
+ self.paren_count = 0
76
+ self.in_attribute = False
77
+ self.anonymous_count = 0
73
78
  self._state = self._state_global
74
79
 
75
80
  def _state_global(self, token):
76
- if token == 'sub':
81
+ if token == 'package':
82
+ self.next(self._state_package_dec)
83
+ elif token == 'sub':
77
84
  self.function_name = ''
78
85
  self.next(self._state_function_dec)
79
86
  elif token == '{':
80
87
  self.brace_count += 1
81
88
  elif token == '}':
82
89
  self.brace_count -= 1
90
+ elif token == '(':
91
+ self.paren_count += 1
92
+ self.next(self._state_function_call)
93
+ elif token == '$' or token == 'my' or token == 'our' or token == 'local':
94
+ self.variable_name = ''
95
+ self.next(self._state_variable)
96
+
97
+ def _state_package_dec(self, token):
98
+ if not token.isspace():
99
+ self.package_name = token
100
+ self.next(self._state_global)
101
+
102
+ def _state_variable(self, token):
103
+ if token == '$':
104
+ # Skip the $ in variable names
105
+ pass
106
+ elif token == '=':
107
+ self.next(self._state_assignment)
108
+ elif token == ';':
109
+ self.variable_name = ''
110
+ self.next(self._state_global)
111
+ elif not token.isspace() and self.variable_name == '':
112
+ self.variable_name = token
113
+
114
+ def _state_assignment(self, token):
115
+ if token == 'sub':
116
+ self.next(self._state_anon_sub)
117
+ elif token == ';':
118
+ self.variable_name = ''
119
+ self.next(self._state_global)
120
+
121
+ def _state_function_call(self, token):
122
+ if token == 'sub':
123
+ # Inline anonymous subroutine as argument
124
+ self.anonymous_count += 1
125
+ full_name = f"<anonymous>"
126
+ if self.package_name:
127
+ full_name = f"{self.package_name}::{full_name}"
128
+
129
+ self.context.try_new_function(full_name)
130
+ self.context.confirm_new_function()
131
+ self.next(self._state_anon_brace_search)
132
+ elif token == ')':
133
+ self.paren_count -= 1
134
+ if self.paren_count == 0:
135
+ self.next(self._state_global)
136
+ elif token == '(':
137
+ self.paren_count += 1
138
+
139
+ def _state_anon_sub(self, token):
140
+ if token == '{':
141
+ self.brace_count = 1
142
+ full_name = '<anonymous>'
143
+ # Use variable name if available for more readable function names
144
+ if self.variable_name:
145
+ full_name = '$' + self.variable_name
146
+
147
+ if self.package_name:
148
+ full_name = f"{self.package_name}::{full_name}"
149
+
150
+ self.context.try_new_function(full_name)
151
+ self.context.confirm_new_function()
152
+ self.next(self._state_function_body)
83
153
 
84
154
  def _state_function_dec(self, token):
85
155
  if token == '{':
86
156
  self.brace_count = 1
87
157
  if self.function_name:
88
- self.context.try_new_function(self.function_name)
158
+ full_name = self.function_name
159
+ if self.package_name:
160
+ full_name = f"{self.package_name}::{self.function_name}"
161
+ self.context.try_new_function(full_name)
89
162
  self.context.confirm_new_function()
90
163
  self.next(self._state_function_body)
164
+ elif token == ':':
165
+ self.in_attribute = True
91
166
  elif token == ';':
167
+ # Forward declaration like "sub func_name;"
168
+ if self.function_name:
169
+ full_name = self.function_name
170
+ if self.package_name:
171
+ full_name = f"{self.package_name}::{self.function_name}"
172
+ self.context.try_new_function(full_name)
173
+ self.context.confirm_new_function()
174
+ # Empty function body
175
+ self.context.end_of_function()
92
176
  self.next(self._state_global)
177
+ elif token == '(':
178
+ # Function with parameter prototype like "sub fetch($)"
179
+ # Save the current function name and look for closing paren
180
+ self.paren_count = 1
181
+ self.next(self._state_function_prototype)
182
+ elif token == 'sub':
183
+ # Handle anonymous subroutine like 'callback(sub { ... })'
184
+ self.anonymous_count += 1
185
+ full_name = f"<anonymous>"
186
+ if self.package_name:
187
+ full_name = f"{self.package_name}::{full_name}"
188
+ self.context.try_new_function(full_name)
189
+ self.context.confirm_new_function()
190
+ self.next(self._state_anon_brace_search)
93
191
  elif not token.isspace():
94
- self.function_name = token
192
+ if not self.in_attribute:
193
+ self.function_name = token
194
+ else:
195
+ # Skip attribute name
196
+ self.in_attribute = False
197
+
198
+ def _state_function_prototype(self, token):
199
+ # Handle parameter prototypes after function name: sub fetch($) { ... }
200
+ if token == ')':
201
+ self.paren_count -= 1
202
+ if self.paren_count == 0:
203
+ # Return to function declaration state to handle the opening brace
204
+ self.next(self._state_function_dec)
205
+ elif token == '(':
206
+ self.paren_count += 1
207
+
208
+ def _state_anon_brace_search(self, token):
209
+ if token == '{':
210
+ self.brace_count = 1
211
+ self.next(self._state_function_body)
212
+ elif token == '(':
213
+ self.paren_count += 1
214
+ elif token == ')':
215
+ self.paren_count -= 1
216
+ if self.paren_count == 0:
217
+ self.next(self._state_global)
95
218
 
96
219
  def _state_function_body(self, token):
97
220
  if token == '{':
@@ -100,4 +223,108 @@ class PerlStates(CodeStateMachine):
100
223
  self.brace_count -= 1
101
224
  if self.brace_count == 0:
102
225
  self.context.end_of_function()
103
- self.next(self._state_global)
226
+ self.next(self._state_global)
227
+ elif token == '?':
228
+ # Ternary operator increases complexity
229
+ self.context.add_condition()
230
+ elif token == ':':
231
+ # Colon part of ternary operator also increases complexity
232
+ self.context.add_condition()
233
+ elif token == 'sub':
234
+ # Check if it's a nested named subroutine or anonymous
235
+ self.next(self._state_nested_sub_dec)
236
+ elif token == '(':
237
+ # Track function calls inside function body
238
+ self.paren_count += 1
239
+ self.next(self._state_nested_call)
240
+
241
+ def _state_nested_sub_dec(self, token):
242
+ if token.isspace():
243
+ return
244
+ elif token == '{':
245
+ # Anonymous sub
246
+ self.brace_count += 1
247
+ self.anonymous_count += 1
248
+ anon_name = f"<anonymous>"
249
+ if self.package_name:
250
+ anon_name = f"{self.package_name}::{anon_name}"
251
+ self.context.add_condition() # Count sub as a condition
252
+ self.next(self._state_function_body)
253
+ else:
254
+ # Named nested sub
255
+ nested_func_name = token
256
+ full_name = nested_func_name
257
+ if self.package_name:
258
+ full_name = f"{self.package_name}::{nested_func_name}"
259
+
260
+ # Save current function state
261
+ saved_func_context = self.context
262
+
263
+ # Create a new function for the nested sub
264
+ self.context.try_new_function(full_name)
265
+ self.context.confirm_new_function()
266
+ self.next(self._state_nested_named_sub_brace_search)
267
+
268
+ def _state_nested_named_sub_brace_search(self, token):
269
+ if token == '{':
270
+ self.brace_count = 1
271
+ self.next(self._state_nested_sub_body)
272
+ elif token.isspace():
273
+ return
274
+ elif token == ':':
275
+ # Handle attributes in nested sub
276
+ self.in_attribute = True
277
+ return
278
+ elif token == ';':
279
+ # Forward declaration
280
+ self.context.end_of_function()
281
+ self.next(self._state_function_body)
282
+
283
+ def _state_nested_sub_body(self, token):
284
+ if token == '{':
285
+ self.brace_count += 1
286
+ elif token == '}':
287
+ self.brace_count -= 1
288
+ if self.brace_count == 0:
289
+ # End the nested function
290
+ self.context.end_of_function()
291
+ # Return to parent function
292
+ self.next(self._state_function_body)
293
+
294
+ def _state_nested_call(self, token):
295
+ if token == 'sub':
296
+ # Inline anonymous subroutine as argument
297
+ self.anonymous_count += 1
298
+ full_name = f"<anonymous>"
299
+ if self.package_name:
300
+ full_name = f"{self.package_name}::{full_name}"
301
+
302
+ self.context.try_new_function(full_name)
303
+ self.context.confirm_new_function()
304
+ self.next(self._state_nested_anon_search)
305
+ elif token == ')':
306
+ self.paren_count -= 1
307
+ if self.paren_count == 0:
308
+ self.next(self._state_function_body)
309
+ elif token == '(':
310
+ self.paren_count += 1
311
+
312
+ def _state_nested_anon_search(self, token):
313
+ if token == '{':
314
+ self.brace_count += 1
315
+ self.next(self._state_nested_anon_body)
316
+ elif token == '(':
317
+ self.paren_count += 1
318
+ elif token == ')':
319
+ self.paren_count -= 1
320
+ if self.paren_count == 0:
321
+ self.next(self._state_function_body)
322
+
323
+ def _state_nested_anon_body(self, token):
324
+ if token == '{':
325
+ self.brace_count += 1
326
+ elif token == '}':
327
+ self.brace_count -= 1
328
+ if self.brace_count == 1: # Back to outer function level
329
+ self.context.end_of_function()
330
+ self.next(self._state_function_body)