Cleanup Codeclimate smells (#11)

* Cleanup Codeclimate smells

* Add Codeclimate badges
This commit is contained in:
Jaco Greeff
2018-12-08 16:37:05 +01:00
committed by GitHub
parent 9aaea82544
commit 91db30af82
11 changed files with 134 additions and 140 deletions
@@ -11,26 +11,27 @@ import store from 'store';
import createOptionItem from '../options/item';
import development from './development';
function callNext (current: SubjectInfo, subject: BehaviorSubject<any>, withTest: boolean) {
const isDevMode = development.isDevelopment();
subject.next(
Object.keys(current).reduce((filtered, key) => {
const { json: { meta: { isTesting = false } = {} } = {} } = current[key];
if (!withTest || isDevMode || isTesting !== true) {
filtered[key] = current[key];
}
return filtered;
}, {} as SubjectInfo)
);
}
export default function genericSubject (keyCreator: (address: string) => string, withTest: boolean = false): AddressSubject {
let current: SubjectInfo = {};
const subject = new BehaviorSubject({});
const next = (): void => {
const isDevMode = development.isDevelopment();
subject.next(
Object
.keys(current)
.reduce((filtered, key) => {
const { json: { meta: { isTesting = false } = {} } = {} } = current[key];
if (!withTest || isDevMode || isTesting !== true) {
filtered[key] = current[key];
}
return filtered;
}, {} as SubjectInfo)
);
};
const next = (): void =>
callNext(current, subject, withTest);
development.subject.subscribe(next);
@@ -6,11 +6,6 @@ import { BehaviorSubject } from 'rxjs';
import { KeyringSectionOption } from '../options/types';
import { KeyringJson } from '../types';
export type SingleAccount = {
json: KeyringJson,
option: KeyringSectionOption
};
export type SingleAddress = {
json: KeyringJson,
option: KeyringSectionOption
@@ -20,12 +15,6 @@ export type SubjectInfo = {
[index: string]: SingleAddress
};
export type AccountSubject = {
add: (account: string, json: KeyringJson) => SingleAccount,
remove: (account: string) => void,
subject: BehaviorSubject<SubjectInfo>
};
export type AddressSubject = {
add: (address: string, json: KeyringJson) => SingleAddress,
remove: (address: string) => void,