Showing 36 of 84 total issues
Function start
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static async start(): Promise<ContentScript> {
logger.info("Starting ContentScript");
const options = await extensionFunctionRegistry.invoke<void, Options>(Actions.GET_OPTIONS);
Function getCSS
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private getCSS(): string {
logger.debug("Generating CSS");
if (this.options.customCSS) {
logger.debug("Using custom CSS");
Function start
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static async start(): Promise<BackgroundScript> {
logger.info("Starting BackgroundScript");
const optionsStorage = new CachedStorage(Constants.OPTIONS_STORAGE_NAME, new BrowserExtensionStorage(
Constants.OPTIONS_STORAGE_NAME,
Function addCss
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private addCss(): void {
if (this.cssElement) {
this.removeCss();
}
Function log
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public log(logLevel: LogLevel, message: string, ...args: Loggable[]): void {
if (logLevel < Logging.getLogLevel()) {
return;
}
Function load
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function load(): Promise<void> {
let options: Options;
try {
options = await extensionFunctionRegistry.invoke<void, Options>(Actions.GET_OPTIONS);
Function highlightComments
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
@bind
private async highlightComments(...comments: RedditComment[]): Promise<void> {
if (!this.currentThread) {
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 update
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function update(): Promise<void> {
const className = element.CSSClassNameInput.value.trim();
const valid = isValidCSSClassName(className);
element.CSSClassNameInput.classList.toggle("text-input--invalid", !valid);
Function highlightComments
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
@bind
private async highlightComments(...comments: RedditComment[]): Promise<void> {
if (!this.currentThread) {
return;
}
Function invoke
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public async invoke<T, R>(key: string, arg?: T): Promise<R> {
const func = this.functions.get(key as string);
if (func) {
// Function is not remote
Function highlightComment
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public highlightComment(comment: RedditComment): void {
logger.info("Highlighting comment", {
id: comment.id,
time: comment.time.toISOString(),
className: this.options.className
Function highlightComment
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public highlightComment(comment: RedditComment): void {
logger.info("Highlighting comment", {
id: comment.id,
time: comment.time.toISOString(),
className: this.options.className
Function messageListener
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
@bind
private messageListener(request: object | void): Promise<InvocationResponse<unknown>> | void {
if (!request) {
return;
}
Function addCss
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private addCss(): void {
if (this.cssElement) {
this.removeCss();
}
- 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 getCSS
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private getCSS(darkMode: boolean): string {
logger.debug("Generating CSS");
if (this.options.customCSS) {
logger.debug("Using custom CSS");
Function getCSS
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private getCSS(darkMode: boolean): string {
logger.debug("Generating CSS");
if (this.options.customCSS) {
logger.debug("Using custom CSS");
- 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 messageListener
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
@bind
private messageListener(request: object | void): Promise<InvocationResponse<unknown>> | void {
if (!request) {
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 onThreadOpened
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public get onThreadOpened(): Subscribable<RedditCommentThread> {
if (!isACommentThread()) {
return this._onThreadOpened;
}
Function save
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function save(): Promise<void> {
const options: Partial<Options> = {
backColor: element.backgroundColorPicker.value,
backNightColor: element.backgroundNightColorPicker.value,
frontColor: element.textColorPicker.value,
Function initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private initialize(): void {
const root = document.querySelector(".sitetable.nestedlisting");
if (!root) {
return;