Failed Conditions
Branch v2.1.0 (e76e15)
by Sander
07:59
created

js/importers/importer-teampass.js   A

Complexity

Total Complexity 4
Complexity/F 1.33

Size

Lines of Code 38
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 38
rs 10
c 1
b 0
f 0
wmc 4
mnd 1
bc 4
fnc 3
bpm 1.3333
cpm 1.3333
noi 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
B PassmanImporter.teamPassCsv.readFile 0 25 1
B 0 37 1
1
/**
2
 * Nextcloud - passman
3
 *
4
 * @copyright Copyright (c) 2016, Sander Brand ([email protected])
5
 * @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected])
6
 * @license GNU AGPL version 3 or any later version
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
// Importers should always start with this
24
/** global: PassmanImporter */
25
var PassmanImporter = PassmanImporter || {};
1 ignored issue
show
Bug introduced by
The variable PassmanImporter seems to be never initialized.
Loading history...
26
(function(window, $, PassmanImporter) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
27
	'use strict';
28
	// Define the importer
29
	PassmanImporter.teamPassCsv = {
30
		info: {
31
			name: 'TeamPass csv',
32
			id: 'teamPassCsv',
33
			description: 'Go to Tools -> Export. Select Comma Separated Values, All entries then continue.'
34
		}
35
	};
36
37
	PassmanImporter.teamPassCsv.readFile = function (file_data) {
38
		/** global: C_Promise */
39
		return new C_Promise(function(){
40
			var parsed_csv = PassmanImporter.readCsv(file_data, false);
41
			var credential_list = [];
42
			for (var i = 0; i < parsed_csv.length; i++) {
43
				var row = parsed_csv[i];
44
				var _credential = PassmanImporter.newCredential();
45
				_credential.label = row[1];
46
				_credential.description = row[2];
47
				_credential.password = row[3];
48
				_credential.username = row[4];
49
50
				var progress = {
51
					percent: i/parsed_csv.length*100,
52
					loaded: i,
53
					total: parsed_csv.length
54
				};
55
56
				credential_list.push(_credential);
57
				this.call_progress(progress);
58
			}
59
			this.call_then(credential_list);
60
		})
0 ignored issues
show
Coding Style introduced by
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
61
	};
62
})(window, $, PassmanImporter);