RemoteStorage
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class RemoteStorage {
/**
* Pending get/put/delete calls
* @private
*/
Function constructor
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
constructor (cfg?: object) {
// Initial configuration property settings.
// TODO use modern JS to merge object properties
if (typeof cfg === 'object') { extend(config, cfg); }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function constructor
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor (cfg?: object) {
// Initial configuration property settings.
// TODO use modern JS to merge object properties
if (typeof cfg === 'object') { extend(config, cfg); }
Function connect
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
connect (userAddress: string, token?: string): void {
this.setBackend('remotestorage');
if (userAddress.indexOf('@') < 0 && !userAddress.match(/^(https?:\/\/)?[^\s\/$\.?#]+\.[^\s]*$/)) {
this._emit('error', new RemoteStorage.DiscoveryError("Not a valid user address or URL."));
return;
Function disconnect
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
disconnect (): void {
if (this.remote) {
this.remote.configure({
userAddress: null,
href: null,
Function setApiKeys
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
setApiKeys (apiKeys: {[key in ApiKeyType]?: string}): void | boolean {
const validTypes: string[] = [ApiKeyType.GOOGLE, ApiKeyType.DROPBOX];
if (typeof apiKeys !== 'object' || !Object.keys(apiKeys).every(type => validTypes.includes(type))) {
console.error('setApiKeys() was called with invalid arguments') ;
return false;
Function connect
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
connect (userAddress: string, token?: string): void {
this.setBackend('remotestorage');
if (userAddress.indexOf('@') < 0 && !userAddress.match(/^(https?:\/\/)?[^\s\/$\.?#]+\.[^\s]*$/)) {
this._emit('error', new RemoteStorage.DiscoveryError("Not a valid user address or URL."));
return;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function authorize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
authorize (options: AuthorizeOptions): void {
this.access.setStorageType(this.remote.storageApi);
if (typeof options.scope === 'undefined') {
options.scope = this.access.scopeParameter;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"