aperta-principium/Interclip

View on GitHub

Showing 22 of 138 total issues

File file.ts has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { a11yClick, alertUser } from "./menu";
import { formatBytes } from "./lib/utils";
import { initTabs } from "./lib/tabs";

const modal = document.getElementById("modal") as HTMLDialogElement;
Severity: Minor
Found in js/file.ts - About 4 hrs to fix

    Function uploadFile has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function uploadFile(file: File) {
      const formData = new FormData();
      formData.append("uploaded_file", file);
    
      modal.showModal();
    Severity: Major
    Found in js/file.ts - About 4 hrs to fix

      Function triggerCallback has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      function triggerCallback(e: DragEvent | Event, callback: () => {}) {
        if (!callback || typeof callback !== "function") {
          return;
        }
      
      
      Severity: Minor
      Found in js/file.ts - About 3 hrs 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 makeDroppable has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function makeDroppable(element: HTMLElement, callback: any) {
        const input = document.createElement("input");
        input.setAttribute("type", "file");
        input.setAttribute("multiple", "false");
        input.style.display = "none";
      Severity: Major
      Found in js/file.ts - About 2 hrs to fix

        Function uploadFile has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function uploadFile(file: File) {
          const formData = new FormData();
          formData.append("uploaded_file", file);
        
          modal.showModal();
        Severity: Minor
        Found in js/file.ts - About 2 hrs 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

        File menu.ts has 254 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import sweetAlert, { SweetAlertOptions } from "sweetalert2";
        import * as DarkModeToggle from "dark-mode-toggle";
        
        // Get the modal
        const settingsModal = document.getElementById("settingsModal")!;
        Severity: Minor
        Found in js/menu.ts - About 2 hrs to fix

          Function validate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          function validate()
          {
              // Start the session
              if (session_status() !== 2) {
                  session_start();
          Severity: Minor
          Found in includes/anti-csrf.php - 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

          Method createClip has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createClip($url)
          {
              noteLimit();
          
              $err = "";
          Severity: Minor
          Found in includes/components/new.php - About 1 hr to fix

            Function handleRequest has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            async function handleRequest(request) {
              const method = request.url.split("/")[3];
              const { searchParams } = new URL(request.url);
              const urlRegex = new RegExp(
                /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/
            Severity: Minor
            Found in api/worker.js - 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 handleTabNavigation has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const handleTabNavigation = (e) => {
              const key = e.key;
              const currentTab = e.target.parentElement as HTMLUListElement;
              const tabsArray = Array.from(tabs) as HTMLUListElement[];
            
            
            Severity: Minor
            Found in js/lib/tabs.ts - About 1 hr to fix

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

              function createClip($url)
              {
                  noteLimit();
              
                  $err = "";
              Severity: Minor
              Found in includes/components/new.php - 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 triggerCallback has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function triggerCallback(e: DragEvent | Event, callback: () => {}) {
                if (!callback || typeof callback !== "function") {
                  return;
                }
              
              
              Severity: Minor
              Found in js/file.ts - About 1 hr to fix

                Method getOS has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function getOS()
                {
                
                    global $user_agent;
                
                
                Severity: Minor
                Found in includes/lib/functions.php - About 1 hr to fix

                  Function updateFileStats has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const updateFileStats = async () => {
                    if (!(filesSpan && filesSizeSpan)) {
                      return;
                    }
                  
                  
                  Severity: Minor
                  Found in js/admin.ts - About 1 hr to fix

                    Function writeDb has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function writeDb($url)
                    {
                      include_once "includes/lib/init.php";
                      include_once "includes/components/new.php";
                    
                    
                    Severity: Minor
                    Found in public/api/set.php - 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 noteLimit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function noteLimit()
                    {
                    
                        if ($GLOBALS["redisAvailable"]) {
                            // The IP is from the shared internet
                    Severity: Minor
                    Found in includes/components/rate.php - About 45 mins 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

                    Avoid too many return statements within this function.
                    Open

                        return new Response(
                          JSON.stringify({
                            status: "error",
                            result: "there is nothing to do, specify a method",
                          }),
                    Severity: Major
                    Found in api/worker.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return new Response(JSON.stringify({ status: "success", result: code }), {
                            headers: {
                              "content-type": "application/json;charset=UTF-8",
                            },
                            status: 200,
                      Severity: Major
                      Found in api/worker.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return new Response(
                                JSON.stringify({ status: "error", result: "invalid URL specified" }),
                                {
                                  headers: {
                                    "content-type": "application/json;charset=UTF-8",
                        Severity: Major
                        Found in api/worker.js - About 30 mins to fix

                          Function storeRedis has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          function storeRedis($key, $value, $expiration = 60 * 60 * 24 * 7)
                          {
                          
                              if ($GLOBALS["redisAvailable"] && $GLOBALS["redis"]->ping()) {
                                  $redisCached = $GLOBALS["redis"]->get($key);
                          Severity: Minor
                          Found in includes/components/redis.php - About 25 mins 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

                          Severity
                          Category
                          Status
                          Source
                          Language