Showing 146 of 349 total issues
Function init
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function init(config: Config) {
// Check that an appKey was provided
if (config.kinveyConfig.appKey === null || config.kinveyConfig.appKey === undefined) {
throw new KinveyError('No app key was provided to initialize the Kinvey JavaScript SDK.');
}
Function collection
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export function collection(collectionName: string, type = DataStoreType.Cache, options: any = {}) {
let datastore;
const tagWasPassed = options && ('tag' in options);
if (collectionName == null || !isString(collectionName)) {
- 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 addSyncEvent
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async addSyncEvent(event: SyncEvent, docs: any) {
const syncCache = new SyncCache(this.tag);
let singular = false;
let syncDocs: any = [];
let docsToSync = docs;
Function loginWithPopup
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function loginWithPopup(clientId: string, redirectUri: string, version?: string | number): Promise<string> {
return new Promise(async (resolve, reject) => {
const url = formatKinveyAuthUrl(`/${getVersion(version)}/oauth/auth`, {
client_id: clientId,
redirect_uri: redirectUri,
Function findById
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
findById(id: string, options: any = {}) {
const stream = Observable.create(async (observer: any) => {
try {
// if (!id) {
// throw new Error('No id was provided. A valid id is required.');
Function create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async create(docs: any, options: any = {}) {
const batchSize = 100;
const apiVersion = getApiVersion();
if (isArray(docs)) {
- 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 matches
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
matches(field: string, expression: any, options: { ignoreCase?: boolean, multiline?: boolean, extended?: boolean, dotMatchesAll?: boolean } = {}) {
const flags = [];
let regExp = expression;
if (!(regExp instanceof RegExp)) {
- 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 send
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function send(request: any) {
const { url, method, headers, body, timeout } = request;
let response;
// Add kinvey device information headers
Function send
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function send(request: any) {
const { url, method, headers, body, timeout } = request;
let response;
// Add kinvey device information headers
Function find
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
find(query?: Query, options: any = {}) {
const stream = Observable.create(async (observer: any) => {
try {
if (query && !(query instanceof Query)) {
throw new KinveyError('Invalid query. It must be an instance of the Query class.');
Function uploadFile
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function uploadFile(url: string, file: any, metadata: any, options: any = {}): Promise<any> {
const { count = 0, maxBackoff = MAX_BACKOFF } = options;
let { start = 0 } = options;
const requestHeaders = new HttpHeaders(options.headers);
Function group
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
group(aggregation: Aggregation, options: any = {}) {
const stream = Observable.create(async (observer: any) => {
try {
if (!(aggregation instanceof Aggregation)) {
throw new KinveyError('Invalid aggregation. It must be an instance of the Aggregation class.');
Function _createMany
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async _createMany(docs: any, options: any = {}) {
const apiVersion = getApiVersion();
if (apiVersion < 5) {
throw new KinveyError('Unable to create an array of entities. Please create entities one by one or use API version 5 or newer.');
}
Function stream
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const stream = Observable.create(async (observer: any) => {
try {
// if (!id) {
// throw new Error('No id was provided. A valid id is required.');
// }
Function count
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
count(query?: Query, options: any = {}) {
const stream = Observable.create(async (observer: any) => {
try {
if (query && !(query instanceof Query)) {
throw new KinveyError('Invalid query. It must be an instance of the Query class.');
Function update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async update(data: object, options: { timeout?: number } = {}) {
const body = Object.assign({}, this.data, data);
if (!data) {
throw new KinveyError('No user was provided to be updated.');
Function open
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
open(url = '/') {
if (this._open !== true) {
const webViewIntercept = (webview: any, error: any, url: string): boolean => {
let urlStr = '';
Function stream
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const stream = Observable.create(async (observer: any) => {
try {
if (query && !(query instanceof Query)) {
throw new KinveyError('Invalid query. It must be an instance of the Query class.');
}
Function constructor
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
constructor(popupWindow: Window) {
super();
this.popupWindow = popupWindow;
this.interval = window.setInterval(() => {
if (popupWindow.closed) {
- 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 find
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
find(query?: Query, options: any = {}) {
const stream = Observable.create(async (observer: any) => {
try {
if (query && !(query instanceof Query)) {
throw new KinveyError('Invalid query. It must be an instance of the Query class.');
- 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"