elabftw/elabftw

View on GitHub
src/Import/Zip.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method dbInsert has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function dbInsert($item): void
    {
        $Teams = new Teams($this->Users, $this->Users->userData['team']);
        // the body is updated after it has been fixed by the uploaded files with correct long_name
        $sql = 'INSERT INTO items(team, title, date, userid, category, status, canread, canwrite, canbook, elabid, metadata)
Severity: Major
Found in src/Import/Zip.php - About 2 hrs to fix

    Function importAll has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        private function importAll(array $json): void
        {
            // do we need to update data: don't sanitize input, escape output
            // if the data/meta keys exist, it's a new zip, otherwise it's an old one that needs transformation
            if (!array_key_exists('data', $json)) {
    Severity: Minor
    Found in src/Import/Zip.php - 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

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

        private function dbInsert($item): void
        {
            $Teams = new Teams($this->Users, $this->Users->userData['team']);
            // the body is updated after it has been fixed by the uploaded files with correct long_name
            $sql = 'INSERT INTO items(team, title, date, userid, category, status, canread, canwrite, canbook, elabid, metadata)
    Severity: Minor
    Found in src/Import/Zip.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 importAll has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function importAll(array $json): void
        {
            // do we need to update data: don't sanitize input, escape output
            // if the data/meta keys exist, it's a new zip, otherwise it's an old one that needs transformation
            if (!array_key_exists('data', $json)) {
    Severity: Minor
    Found in src/Import/Zip.php - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status