Showing 146 of 349 total issues
Function find
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async find(query?: Query, options: any = {}) {
if (query && !(query instanceof Query)) {
throw new KinveyError('query is not 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"
Further reading
Function count
has a Cognitive Complexity of 10 (exceeds 5 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.');
- 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 uploadFile
has a Cognitive Complexity of 10 (exceeds 5 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);
- 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 getTokenWithCode
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getTokenWithCode(code: string, clientId: string, redirectUri: string, options: GetTokenWithCodeOptions = {}) {
const request = new KinveyHttpRequest({
method: HttpRequestMethod.POST,
headers: new KinveyHttpHeaders({
'Content-Type': () => 'application/x-www-form-urlencoded',
Function findById
has 27 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 createEntity
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createEntity = async (syncDocId, entityId): Promise<any> => {
let doc: any = await cache.findById(entityId);
let local = false;
try {
Function send
has 27 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 process
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
process(docs: any = []) {
// eslint-disable-next-line no-new-func
const reduceFn = new Function('doc', 'out', this.reduceFn.replace(/function[\s\S]*?\([\s\S]*?\)/, ''));
let filteredDocs = docs;
Function find
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async find(query?: Query, options: any = {}) {
if (query && !(query instanceof Query)) {
throw new KinveyError('query is not an instance of the Query class.')
}
Function getTokenWithUsernamePassword
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getTokenWithUsernamePassword(username: string, password: string, clientId: string, options: GetTokenWithUsernamePasswordOptions = {}) {
const request = new KinveyHttpRequest({
method: HttpRequestMethod.POST,
headers: new KinveyHttpHeaders({
'Content-Type': () => 'application/x-www-form-urlencoded',
Function uploadFile
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function uploadFile(url: string, file: File, metadata: any, options: any = {}): Promise<any> {
return new Promise((resolve, reject) => {
const session = bghttp.session('file-upload');
const request = {
url,
Function removeById
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async removeById(id: string, options: any = {}) {
const autoSync = options.autoSync === true || this.autoSync;
const cache = new DataStoreCache(this.collectionName, this.tag);
const sync = new Sync(this.collectionName, this.tag);
let count = 0;
Function matches
has 26 lines of code (exceeds 25 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)) {
Function stream
has 26 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 save
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
save(docs: any): Promise<any> {
return queue.add(async () => {
let docsToSave = docs;
let singular = false;
Function send
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function send(request: any): Promise<any> {
const { url, method, headers, body, timeout } = request;
const kinveyUrlRegex = /kinvey\.com/gm;
// Add kinvey device information headers
Function stream
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 findById
has a Cognitive Complexity of 9 (exceeds 5 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.');
- 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
Avoid deeply nested control flow statements. Open
if (currentContent !== micInfoPlistFileContent) {
fs.writeFileSync(destinationInfoPlistFile, micInfoPlistFileContent);
}
Function signup
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export async function signup(data?: object | User, options: { timeout?: number } = {}) {
if (data && !isPlainObject(data)) {
throw new KinveyError('The provided data must be an object.');
}
- 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"