aesy/reddit-comment-highlights

View on GitHub

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);

Severity: Major
Found in src/content/ContentScript.ts - About 2 hrs to fix

    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");
    Severity: Major
    Found in src/reddit/OldRedditCommentHighlighter.ts - About 2 hrs to fix

      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,
      Severity: Major
      Found in src/background/BackgroundScript.ts - About 2 hrs to fix

        Function addCss has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private addCss(): void {
                if (this.cssElement) {
                    this.removeCss();
                }
        
        
        Severity: Major
        Found in src/reddit/RedesignRedditCommentHighlighter.ts - About 2 hrs to fix

          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;
                  }
          
          
          Severity: Minor
          Found in src/logger/KeyValueLogger.ts - About 1 hr to fix

            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);
            Severity: Minor
            Found in src/options/OptionsPage.ts - About 1 hr to fix

              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;
                      }
              Severity: Minor
              Found in src/content/ContentScript.ts - About 1 hr to fix

              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);
              Severity: Minor
              Found in src/options/OptionsPage.ts - About 1 hr to fix

                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;
                        }
                Severity: Minor
                Found in src/content/ContentScript.ts - About 1 hr to fix

                  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
                  Severity: Minor
                  Found in src/registry/RemoteFunctionBrowserExtensionRegistry.ts - About 1 hr to fix

                    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
                    Severity: Minor
                    Found in src/reddit/OldRedditCommentHighlighter.ts - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in src/reddit/RedesignRedditCommentHighlighter.ts - About 1 hr to fix

                        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;
                                }
                        Severity: Minor
                        Found in src/registry/RemoteFunctionBrowserExtensionRegistry.ts - About 1 hr to fix

                          Function addCss has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private addCss(): void {
                                  if (this.cssElement) {
                                      this.removeCss();
                                  }
                          
                          
                          Severity: Minor
                          Found in src/reddit/RedesignRedditCommentHighlighter.ts - About 1 hr to fix

                          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");
                          Severity: Minor
                          Found in src/reddit/RedesignRedditCommentHighlighter.ts - About 1 hr to fix

                            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");
                            Severity: Minor
                            Found in src/reddit/RedesignRedditCommentHighlighter.ts - About 1 hr to fix

                            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;
                                    }
                            Severity: Minor
                            Found in src/registry/RemoteFunctionBrowserExtensionRegistry.ts - About 1 hr to fix

                            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;
                                    }
                            
                            
                            Severity: Minor
                            Found in src/reddit/OldRedditPage.ts - About 1 hr to fix

                              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,
                              Severity: Minor
                              Found in src/options/OptionsPage.ts - About 1 hr to fix

                                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;
                                Severity: Minor
                                Found in src/reddit/OldRedditPage.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language