lizard 1.17.20__py2.py3-none-any.whl → 1.17.21__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.20
3
+ Version: 1.17.21
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/
@@ -72,6 +72,7 @@ A list of supported languages:
72
72
  - Solidity
73
73
  - Erlang
74
74
  - Zig
75
+ - Perl
75
76
 
76
77
  By default lizard will search for any source code that it knows and mix
77
78
  all the results together. This might not be what you want. You can use
@@ -25,9 +25,9 @@ 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=IB2eWTQRCnG9RBY141iHFEvno0xjjBabRujvFSaRAfg,182
28
+ lizard_ext/version.py,sha256=3mpAZCQFxtZ-yEx47ZY238MZafb6rPxy9lZff5hymyA,182
29
29
  lizard_ext/xmloutput.py,sha256=-cbh0he4O_X-wX56gkv9AnSPNN0qvR7FACqlBeezUS4,5609
30
- lizard_languages/__init__.py,sha256=2mvrPWMJVCq981kMjoAPEi2O07C8vo-vUWOG_wp7vKQ,1473
30
+ lizard_languages/__init__.py,sha256=ArNmUrVSU6HFxhDka1-vWMZpVIM39P-gqv6BoOLNMV8,1522
31
31
  lizard_languages/clike.py,sha256=INd5tkvwEVZm7dx2yHG2OIFHZn7JzQGmnT9WQNFZ2XU,11110
32
32
  lizard_languages/code_reader.py,sha256=P0PkE4QZBWOEj6cFHA4hj3hcLZLcGnqH31EmtltxlaE,6240
33
33
  lizard_languages/csharp.py,sha256=EfFAIOIcJXUUhXTlZApXGSlzG34NZvHM9OSe6m7hpv0,2141
@@ -44,6 +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
48
  lizard_languages/php.py,sha256=8OufyR2TIWyf3bXuTmp37Vwf_tEPF4YV5M3i5_jnguA,1377
48
49
  lizard_languages/python.py,sha256=1e0dKbl82z-i_5dswkKaFIV5WuQDKztPHh9UNmSTLyE,3848
49
50
  lizard_languages/ruby.py,sha256=HL1ZckeuUUJU3QSVAOPsG_Zsl0C6X2PX5_VaWqclzkM,2277
@@ -59,9 +60,9 @@ lizard_languages/ttcn.py,sha256=ygjw_raBmPF-4mgoM8m6CAdyEMpTI-n1kZJK1RL4Vxo,2131
59
60
  lizard_languages/typescript.py,sha256=P_rphg5AXJAk9QetmvVKc2911ilPmiRa0Qa5fHWleJg,3829
60
61
  lizard_languages/vue.py,sha256=KXUBUo2R1zNF8Pffrz_KsQEN44m5XFRMoGXylxKUeT0,1038
61
62
  lizard_languages/zig.py,sha256=NX1iyBstBuJFeAGBOAIaRfrmeBREne2HX6Pt4fXZZTQ,586
62
- lizard-1.17.20.dist-info/LICENSE.txt,sha256=05ZjgQ8Cl1dD9p0BhW-Txzkc5rhCogGJVEuf1GT2Y_M,1303
63
- lizard-1.17.20.dist-info/METADATA,sha256=RPB3J8UEOaOw7SP0BNMOf7JiU_sXiF0eXiVrYdCiwFA,15745
64
- lizard-1.17.20.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
65
- lizard-1.17.20.dist-info/entry_points.txt,sha256=ZBqPhu-J3NoGGW5vn2Gfyoo0vdVlgBgM-wlNm0SGYUQ,39
66
- lizard-1.17.20.dist-info/top_level.txt,sha256=5NTrTaOLhHuTzXaGcZPKfuaOgUv7WafNGe0Zl5aycpg,35
67
- lizard-1.17.20.dist-info/RECORD,,
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,,
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.20"
6
+ version = "1.17.21"
@@ -24,6 +24,7 @@ from .solidity import SolidityReader
24
24
  from .jsx import JSXReader
25
25
  from .tsx import TSXReader
26
26
  from .vue import VueReader
27
+ from .perl import PerlReader
27
28
 
28
29
 
29
30
  def languages():
@@ -52,6 +53,7 @@ def languages():
52
53
  JSXReader,
53
54
  TSXReader,
54
55
  VueReader,
56
+ PerlReader,
55
57
  ]
56
58
 
57
59
 
@@ -0,0 +1,103 @@
1
+ '''
2
+ Language parser for Perl
3
+ '''
4
+
5
+ from .code_reader import CodeReader, CodeStateMachine
6
+ from .script_language import ScriptLanguageMixIn
7
+
8
+
9
+ class PerlCommentsMixin(object):
10
+ @staticmethod
11
+ def get_comment_from_token(token):
12
+ if token.startswith('#'):
13
+ return token # Return the entire comment including #
14
+ return None
15
+
16
+
17
+ class PerlReader(CodeReader, ScriptLanguageMixIn):
18
+ # pylint: disable=R0903
19
+
20
+ ext = ['pl', 'pm']
21
+ language_names = ['perl']
22
+ _conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach', '&&', '||', '?', 'when'])
23
+
24
+ def __init__(self, context):
25
+ super(PerlReader, self).__init__(context)
26
+ self.parallel_states = [PerlStates(context)]
27
+
28
+ def preprocess(self, tokens):
29
+ comment = None
30
+ for token in tokens:
31
+ if comment is not None:
32
+ if token == '\n':
33
+ yield comment
34
+ comment = None
35
+ yield token
36
+ else:
37
+ comment += token
38
+ elif token == '#':
39
+ comment = token
40
+ else:
41
+ yield token
42
+ if comment is not None:
43
+ yield comment
44
+
45
+ def _state(self, token):
46
+ current_state = self.parallel_states[-1]
47
+ if token == '\n':
48
+ return
49
+ return current_state.state(token)
50
+
51
+ @staticmethod
52
+ def get_comment_from_token(token):
53
+ if token.startswith('#'):
54
+ # For forgiveness comments, return the entire comment
55
+ stripped = token.lstrip('#').strip()
56
+ if stripped.startswith('lizard forgives') or stripped.startswith('#lizard forgives'):
57
+ return '#lizard forgives' # Return standardized forgiveness comment
58
+ return stripped # Return the stripped comment for other cases
59
+ return None
60
+
61
+ @staticmethod
62
+ def generate_tokens(source_code, addition='', token_class=None):
63
+ return ScriptLanguageMixIn.generate_common_tokens(source_code, addition, token_class)
64
+
65
+
66
+ class PerlStates(CodeStateMachine):
67
+ _conditions = set(['if', 'elsif', 'unless', 'while', 'until', 'for', 'foreach'])
68
+
69
+ def __init__(self, context):
70
+ super(PerlStates, self).__init__(context)
71
+ self.function_name = ''
72
+ self.brace_count = 0
73
+ self._state = self._state_global
74
+
75
+ def _state_global(self, token):
76
+ if token == 'sub':
77
+ self.function_name = ''
78
+ self.next(self._state_function_dec)
79
+ elif token == '{':
80
+ self.brace_count += 1
81
+ elif token == '}':
82
+ self.brace_count -= 1
83
+
84
+ def _state_function_dec(self, token):
85
+ if token == '{':
86
+ self.brace_count = 1
87
+ if self.function_name:
88
+ self.context.try_new_function(self.function_name)
89
+ self.context.confirm_new_function()
90
+ self.next(self._state_function_body)
91
+ elif token == ';':
92
+ self.next(self._state_global)
93
+ elif not token.isspace():
94
+ self.function_name = token
95
+
96
+ def _state_function_body(self, token):
97
+ if token == '{':
98
+ self.brace_count += 1
99
+ elif token == '}':
100
+ self.brace_count -= 1
101
+ if self.brace_count == 0:
102
+ self.context.end_of_function()
103
+ self.next(self._state_global)