Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions lib/modules/CommonUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use babel';

import { groupBy, isArray, keys } from 'lodash';
import { groupBy, isArray, keys, values, find } from 'lodash';

import { DB } from './Database';
import { Store } from './Store';
Expand Down Expand Up @@ -74,7 +74,7 @@ export class CommonUtils {
// Others -----------------------------------------------------------------------------------------------------------

static getIndicators() {
const { table } = Store.get(STORE_KEYS.analysisResults);
const { table, origin } = Store.get(STORE_KEYS.analysisResults);
if (!isArray(table)) {
return {
info: 0,
Expand All @@ -85,20 +85,37 @@ export class CommonUtils {
};
}

const info = table.filter(row => row.severity === SEVERITY.info).length;
const warning = table.filter(row => row.severity === SEVERITY.warning).length;
const critical = table.filter(row => row.severity === SEVERITY.critical).length;
const { files, suggestions } = origin;

const filesCount = keys(files).length;
const suggestionsList = values(suggestions);
const messagesGroups = groupBy(suggestionsList, suggestion => suggestion.id);

let info = 0;
let warning = 0;
let critical = 0;

keys(messagesGroups).forEach(id => {
const suggestion = find(suggestionsList, { id });
if (!suggestion) {
return;
}

const { severity } = suggestion;

info += (severity === SEVERITY.info) ? 1 : 0;
warning += (severity === SEVERITY.warning) ? 1 : 0;
critical += (severity === SEVERITY.critical) ? 1 : 0;
});

const total = info + warning + critical;
const fileGroups = groupBy(table, (row) => row.fileName);
const files = keys(fileGroups).length;

return {
info,
warning,
critical,
total,
files,
files: filesCount,
};
}
}
19 changes: 14 additions & 5 deletions lib/modules/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,21 @@ class PluginManager {
}

openLoginDialog() {
if (this.loginDialog) {
return;
}

const onClickLogin = async () => {
Store.set(STORE_KEYS.loginInProcess, true);
if (this.loginDialog) {
Store.set(STORE_KEYS.loginInProcess, true);

this.loginDialog.dismiss();
this.loginDialog = null;

await AuthModule.login();
}

await AuthModule.login();

};

this.loginDialog = atom.notifications.addInfo(MESSAGES.loginPrompt, {
Expand Down Expand Up @@ -254,14 +260,17 @@ class PluginManager {
}

didLogout() {
const loginInProcess = Store.get(STORE_KEYS.loginInProcess);
if (loginInProcess) {
return;
}

Store.setMany({
[STORE_KEYS.accountType]: '',
[STORE_KEYS.sessionToken]: '',
});

if (!this.loginDialog) {
this.openLoginDialog();
}
this.openLoginDialog();
}

// Utils ------------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion spec/deepcode-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ describe('Deepcode Plugin tests', () => {

const checkFiltersPromise = new Promise(resolve => {
dcPackage.checkFilters();
resolve();
setTimeout(() => {
resolve();
}, 100);
});

waitsForPromise(() => checkFiltersPromise);
Expand Down