Showing 35 of 91 total issues
File uppload.ts
has 702 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { UpploadService } from "./service";
import { UpploadEffect } from "./effect";
import { setI18N, translate } from "./helpers/i18n";
import { compressImage, getElements, safeListen } from "./helpers/elements";
import { colorSVG } from "./helpers/assets";
Uppload
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
export class Uppload implements IUppload {
services: UpploadService[] = [new DefaultService(), new UploadingService()];
effects: UpploadEffect[] = [];
isOpen = false;
error?: string;
Function handlers
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
private handlers() {
const openFunction = () => this.open();
const closeFunction = () => this.close();
/**
Function update
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private update() {
if (!this.container) return;
this.hideHelp();
if (this.settings.customClass)
this.container.classList.add(this.settings.customClass);
- 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 canvasToBlob
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export const canvasToBlob = (
canvas: HTMLCanvasElement,
type?: string,
quality?: number
): Promise<Blob> => {
- 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 update
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
private update() {
if (!this.container) return;
this.hideHelp();
if (this.settings.customClass)
this.container.classList.add(this.settings.customClass);
Function getFile
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
getFile(params: IHandlersParams, event: Event) {
event.preventDefault();
const files = (event.target as HTMLInputElement).files;
let file: File | null = null;
if (files) {
- 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 dropHandler
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
dropHandler(params: IHandlersParams, event: DragEvent) {
event.preventDefault();
this.dragStop(params, event);
let file: File | null = null; // getAsFile() returns File | null
if (event.dataTransfer && event.dataTransfer.items) {
- 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 update
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
update(params: IHandlersParams) {
const waiting = params.uppload.container.querySelector(
".camera-waiting"
) as HTMLDivElement | null;
if (waiting) {
Function update
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
update(params: IHandlersParams) {
const waiting = params.uppload.container.querySelector(
".camera-waiting"
) as HTMLDivElement | null;
if (waiting) {
- 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 flattenObject
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export const flattenObject = (ob: any) => {
const toReturn: any = {};
for (const i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if (typeof ob[i] == "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"
Further reading
Function upload
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
upload(file: File | Blob): Promise<string> {
this.emitter.emit("before-upload", file);
return new Promise((resolve, reject) => {
this.navigate("uploading");
let upploadFile = blobToUpploadFile(file);
Function canvasToBlob
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const canvasToBlob = (
canvas: HTMLCanvasElement,
type?: string,
quality?: number
): Promise<Blob> => {
Function getNavbar
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private getNavbar(sidebar = false) {
return `<${sidebar ? "nav" : "div"} class="uppload-services">
${this.services
.filter(service => !service.invisible)
.map(
Function cachedFetch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function cachedFetch<T>(
input: RequestInfo,
settings?: RequestInit
): Promise<T> {
const storage = sessionStorage;
Function dropHandler
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
dropHandler(params: IHandlersParams, event: DragEvent) {
event.preventDefault();
this.dragStop(params, event);
let file: File | null = null; // getAsFile() returns File | null
if (event.dataTransfer && event.dataTransfer.items) {
Function getFile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
getFile(params: IHandlersParams, event: Event) {
event.preventDefault();
const files = (event.target as HTMLInputElement).files;
let file: File | null = null;
if (files) {
Function compressImage
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
new Promise(resolve => {
const imageURL = URL.createObjectURL(file);
const canvas = document.createElement("canvas");
const image = document.createElement("img");
const maxSize = settings.maxSize || [
Function fitImageToContainer
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const fitImageToContainer = (
params: IHandlersParams,
image: HTMLImageElement | HTMLVideoElement
): Promise<void> => {
return new Promise(resolve => {
Function renderContainer
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private renderContainer() {
if (this.container)
this.container.innerHTML = `
<div class="uppload-modal">
<div class="processing-loader"></div>