aperta-principium/Interclip

View on GitHub
includes/components/new.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

    Call to method __construct from undeclared class \mysqli
    Open

        $conn = new mysqli($_ENV['DB_SERVER'], $_ENV['USERNAME'], $_ENV['PASSWORD'], $_ENV['DB_NAME']);
    Severity: Critical
    Found in includes/components/new.php by phan

    Call to method prepare from undeclared class \mysqli
    Open

            $stmt = $conn->prepare('SELECT * FROM userurl WHERE usr = ?');
    Severity: Critical
    Found in includes/components/new.php by phan

    Call to method prepare from undeclared class \mysqli
    Open

            $stmt = $conn->prepare('INSERT INTO userurl (usr, url, date, expires) VALUES (?, ?, NOW(), ?)');
    Severity: Critical
    Found in includes/components/new.php by phan

    Reference to instance property connect_error from undeclared class \mysqli
    Open

        if ($conn->connect_error) {
    Severity: Minor
    Found in includes/components/new.php by phan

    Reference to instance property connect_error from undeclared class \mysqli
    Open

        if ($conn->connect_error) {
    Severity: Minor
    Found in includes/components/new.php by phan

    Call to method prepare from undeclared class \mysqli
    Open

        $stmt = $conn->prepare('SELECT * FROM userurl WHERE url = ?');
    Severity: Critical
    Found in includes/components/new.php by phan

    Reference to instance property connect_error from undeclared class \mysqli
    Open

            die("Connection failed: " . $conn->connect_error);
    Severity: Minor
    Found in includes/components/new.php by phan

    Call to method prepare from undeclared class \mysqli
    Open

        $stmt = $conn->prepare('SELECT * FROM userurl WHERE url = ?');
    Severity: Critical
    Found in includes/components/new.php by phan

    Call to method close from undeclared class \mysqli
    Open

        $conn->close();
    Severity: Critical
    Found in includes/components/new.php by phan

    Returning type array{0:string,1:''|string} but createClip() is declared to return void
    Open

        return [$usr, $err];
    Severity: Minor
    Found in includes/components/new.php by phan

    Call to method close from undeclared class \mysqli
    Open

                $conn->close();
    Severity: Critical
    Found in includes/components/new.php by phan

    Call to method __construct from undeclared class \mysqli
    Open

        $conn = new mysqli($_ENV['DB_SERVER'], $_ENV['USERNAME'], $_ENV['PASSWORD'], $_ENV['DB_NAME']);
    Severity: Critical
    Found in includes/components/new.php by phan

    Reference to instance property connect_error from undeclared class \mysqli
    Open

            die("Connection failed: " . $conn->connect_error);
    Severity: Minor
    Found in includes/components/new.php by phan

    Reference to instance property error from undeclared class \mysqli
    Open

                $err = "Error inserting clip: <br>" . $conn->error;
    Severity: Minor
    Found in includes/components/new.php by phan

    There are no issues that match your filters.

    Category
    Status