Completed
Push — phpunit ( 7f2080...75f541 )
by Marcos
14:28 queued 10:45
created

js/importers/importer-lastpasscsv.js   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 38
rs 8.8571

1 Function

Rating   Name   Duplication   Size   Complexity  
B PassmanImporter.lastpassCsv.readFile 0 26 1
1
// Importers should always start with this
2
var PassmanImporter = PassmanImporter || {};
1 ignored issue
show
Bug introduced by
The variable PassmanImporter seems to be never initialized.
Loading history...
3
(function(window, $, PassmanImporter) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4
	'use strict';
5
	// Define the importer
6
	PassmanImporter.lastpassCsv = {
7
		info: {
8
			name: 'LastPass csv',
9
			id: 'lastpassCsv',
10
			description: 'Create an csv export. Go to More options -> Advanced -> Export -> Last Pass CSV File'
11
		}
12
	};
13
14
	PassmanImporter.lastpassCsv.readFile = function (file_data) {
15
		return new C_Promise(function(){
0 ignored issues
show
Bug introduced by
The variable C_Promise seems to be never declared. If this is a global, consider adding a /** global: C_Promise */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
16
			var parsed_csv = PassmanImporter.readCsv(file_data);
17
			var credential_list = [];
18
			for (var i = 0; i < parsed_csv.length; i++) {
19
				var row = parsed_csv[i];
20
				var _credential = PassmanImporter.newCredential();
21
				_credential.label = PassmanImporter.htmlDecode(row.name);
22
				_credential.username = row.username;
23
				_credential.password = row.password;
24
				_credential.url = row.url;
25
				_credential.tags = [{text: row.grouping}];
26
				_credential.description = row.extra;
27
				if(_credential.label){
28
					credential_list.push(_credential);
29
				}
30
				var progress = {
31
					percent: i/parsed_csv.length*100,
32
					loaded: i,
33
					total: parsed_csv.length
34
				};
35
				this.call_progress(progress);
36
			}
37
			this.call_then(credential_list)
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...
38
		});
39
	};
40
})(window, $, PassmanImporter);