Conditions | 1 |
Total Lines | 77 |
Code Lines | 65 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # -*- coding: utf-8 -*- |
||
88 | @patch('ospd_openvas.daemon.NVTICache') |
||
89 | @patch('ospd_openvas.daemon.MainDB') |
||
90 | def __init__( |
||
91 | self, _MainDBClass: MagicMock = None, NvtiClass: MagicMock = None |
||
92 | ): |
||
93 | assert _MainDBClass |
||
94 | assert NvtiClass |
||
95 | nvti = NvtiClass.return_value |
||
96 | oids = [['mantis_detect.nasl', '1.3.6.1.4.1.25623.1.0.100061']] |
||
97 | nvti.get_oids.return_value = oids |
||
98 | nvti.get_nvt_params.return_value = { |
||
99 | '1': { |
||
100 | 'id': '1', |
||
101 | 'default': '', |
||
102 | 'description': 'Description', |
||
103 | 'name': 'Data length :', |
||
104 | 'type': 'entry', |
||
105 | }, |
||
106 | '2': { |
||
107 | 'id': '2', |
||
108 | 'default': 'no', |
||
109 | 'description': 'Description', |
||
110 | 'name': 'Do not randomize the order in which ports are scanned', # pylint: disable=line-too-long |
||
111 | 'type': 'checkbox', |
||
112 | }, |
||
113 | } |
||
114 | nvti.get_nvt_refs.return_value = { |
||
115 | 'bid': [''], |
||
116 | 'cve': [''], |
||
117 | 'xref': ['URL:http://www.mantisbt.org/'], |
||
118 | } |
||
119 | nvti.get_nvt_metadata.return_value = { |
||
120 | 'category': '3', |
||
121 | 'creation_date': '1237458156', |
||
122 | 'cvss_base_vector': 'AV:N/AC:L/Au:N/C:N/I:N/A:N', |
||
123 | 'excluded_keys': 'Settings/disable_cgi_scanning', |
||
124 | 'family': 'Product detection', |
||
125 | 'filename': 'mantis_detect.nasl', |
||
126 | 'last_modification': ('1533906565'), |
||
127 | 'name': 'Mantis Detection', |
||
128 | 'qod_type': 'remote_banner', |
||
129 | 'required_ports': 'Services/www, 80', |
||
130 | 'solution': 'some solution', |
||
131 | 'solution_type': 'WillNotFix', |
||
132 | 'solution_method': 'DebianAPTUpgrade', |
||
133 | 'impact': 'some impact', |
||
134 | 'insight': 'some insight', |
||
135 | 'summary': ('some summary'), |
||
136 | 'affected': 'some affection', |
||
137 | 'timeout': '0', |
||
138 | 'vt_params': { |
||
139 | '1': { |
||
140 | 'id': '1', |
||
141 | 'default': '', |
||
142 | 'description': 'Description', |
||
143 | 'name': 'Data length :', |
||
144 | 'type': 'entry', |
||
145 | }, |
||
146 | '2': { |
||
147 | 'id': '2', |
||
148 | 'default': 'no', |
||
149 | 'description': 'Description', |
||
150 | 'name': 'Do not randomize the order in which ports are scanned', # pylint: disable=line-too-long |
||
151 | 'type': 'checkbox', |
||
152 | }, |
||
153 | }, |
||
154 | 'refs': { |
||
155 | 'bid': [''], |
||
156 | 'cve': [''], |
||
157 | 'xref': ['URL:http://www.mantisbt.org/'], |
||
158 | }, |
||
159 | } |
||
160 | nvti.get_feed_version.return_value = '123' |
||
161 | |||
162 | super().__init__(niceness=10, lock_file_dir='/tmp') |
||
163 | |||
164 | self.scan_collection.data_manager = FakeDataManager() |
||
165 | |||
174 |