Showing 30 of 60 total issues
File s3-resource.class.ts
has 413 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as path from "path";
import { nanoid } from "nanoid";
import CryptoJS from "crypto-js";
import EventEmitter from "events";
import { flatten, unflatten } from "flat";
File s3-client.class.ts
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as path from "path";
import { chunk } from "lodash";
import { nanoid } from "nanoid";
import { Stream } from "stream";
import EventEmitter from "events";
Function main
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
const s3db = new S3db({
uri: ENV.CONNECTION_STRING,
passphrase: ENV.PASSPRHASE,
parallelism: ENV.PARALLELISM,
S3Resource
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export class S3Resource extends EventEmitter implements ResourceInterface {
name: any;
schema: any;
mapObj: any;
options: any;
Function studyOptions
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
studyOptions() {
if (!this.options.afterUnmap) this.options.beforeMap = {};
if (!this.options.afterUnmap) this.options.afterUnmap = {};
const schema: any = flatten(this.schema, { safe: true });
- 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 main
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
const s3db = new S3db({
uri: ENV.CONNECTION_STRING + Date.now(),
passphrase: ENV.PASSPRHASE,
parallelism: ENV.PARALLELISM,
Function main
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
const s3db = new S3db({
uri: ENV.CONNECTION_STRING,
passphrase: ENV.PASSPRHASE,
parallelism: ENV.PARALLELISM,
Function main
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
const fake = Fakerator();
const s3db = new S3db({
uri: ENV.CONNECTION_STRING,
Function _get
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
async _get({ key }: { key: string }) {
try {
const res = await this.s3Client.getObject(key);
if (!res.Body) 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 main
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
const s3db = new S3db({
uri: ENV.CONNECTION_STRING,
passphrase: ENV.PASSPRHASE,
parallelism: ENV.PARALLELISM,
Function main
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function main() {
const s3db = new S3db({
uri: ENV.CONNECTION_STRING,
passphrase: ENV.PASSPRHASE,
parallelism: ENV.PARALLELISM,
Function getItems
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getItems({
continuationToken = null,
}: {
continuationToken?: string | null;
} = {}) {
Function getContinuationTokenAfterOffset
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async getContinuationTokenAfterOffset({
prefix,
offset = 1000,
}: {
prefix?: string;
- 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 getKeysPage
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getKeysPage({
prefix,
offset = 0,
amount = 100,
}: {
Function update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async update(id: any, attributes: any) {
const obj = await this.get(id);
let attrs1 = flatten(attributes, { safe: true });
let attrs2 = flatten(obj, { safe: true });
Function studyOptions
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
studyOptions() {
if (!this.options.afterUnmap) this.options.beforeMap = {};
if (!this.options.afterUnmap) this.options.afterUnmap = {};
const schema: any = flatten(this.schema, { safe: true });
Function unmap
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
unmap(data: any) {
const obj = Object.entries(data).reduce((acc: any, [key, value]) => {
acc[this.reversedMapObj[key]] = value;
return acc;
}, {});
- 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 deleteObjects
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async deleteObjects(keys: string[]) {
const packages = chunk(keys, 1000);
const { results, errors } = await PromisePool.for(packages)
.withConcurrency(this.parallelism)
Function getContinuationTokenAfterOffset
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getContinuationTokenAfterOffset({
prefix,
offset = 1000,
}: {
prefix?: string;
Function insert
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async insert(attributes: any) {
let { id, ...attrs }: { id: any; attrs: any } = flatten(attributes, {
safe: true,
});