elabftw/elabftw

View on GitHub

Showing 221 of 356 total issues

Users has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class Users implements RestInterface
{
    public bool $needValidation = false;

    public array $userData = array();
Severity: Minor
Found in src/models/Users.php - About 3 hrs to fix

    QueryBuilderVisitor has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class QueryBuilderVisitor implements Visitor
    {
        public function buildWhere(Visitable $parsedQuery, VisitorParameters $parameters): WhereCollector
        {
            return $parsedQuery->accept($this, $parameters);
    Severity: Minor
    Found in src/services/advancedSearchQuery/visitors/QueryBuilderVisitor.php - About 3 hrs to fix

      Method createOne has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function createOne(
              string $email,
              array $teams,
              string $firstname = '',
              string $lastname = '',
      Severity: Major
      Found in src/models/Users.php - About 3 hrs to fix

        Function edit has 83 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          edit(): Promise<void> {
            return this.read().then(json => {
              this.editor.refresh(json as ValidMetadata);
              // do nothing more if there is no extra_fields in our json
              if (!Object.prototype.hasOwnProperty.call(json, 'extra_fields')) {
        Severity: Major
        Found in src/ts/Metadata.class.ts - About 3 hrs to fix

          AutoComplete has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class AutoComplete {
            editor;
            options = {};
            query = '';
            hasFocus = true;
          Severity: Minor
          Found in src/js/tinymce-plugins/mention/plugin.js - About 3 hrs to fix

            Method notif has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function notif(array $notif): string
                {
                    $relativeMoment = '<br><span class="relative-moment" title="%s"></span>';
            
                    return match (Notifications::from($notif['category'])) {
            Severity: Major
            Found in src/services/Transform.php - About 3 hrs to fix

              Method formatMetadata has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function formatMetadata(string $json): string
                  {
                      $final = '';
                      $Metadata = new Metadata($json);
                      $extraFields = $Metadata->getExtraFields();
              Severity: Major
              Found in src/classes/TwigFilters.php - About 3 hrs to fix

                Method execute has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function execute(InputInterface $input, OutputInterface $output): int
                    {
                        $Db = Db::getConnection();
                
                        $queryItemsOrExperiment = "SELECT DISTINCT `id`, `body`, `userid`
                Severity: Major
                Found in src/commands/AddMissingLinks.php - About 3 hrs to fix

                  File TeamGroups.php has 291 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  /**
                   * @package   Elabftw\Elabftw
                   * @author    Nicolas CARPi <nico-git@deltablot.email>
                  Severity: Minor
                  Found in src/models/TeamGroups.php - About 3 hrs to fix

                    File Eln.php has 289 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    
                    /**
                     * @author Nicolas CARPi <nico-git@deltablot.email>
                     * @copyright 2022 Nicolas CARPi
                    Severity: Minor
                    Found in src/Import/Eln.php - About 2 hrs to fix

                      Function tryAuth has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function tryAuth(): AuthResponse
                          {
                              $record = $this->getRecord();
                              $dn = $record->getDn();
                              if ($dn === null) {
                      Severity: Minor
                      Found in src/Auth/Ldap.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

                      File team.ts has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /**
                       * @author Nicolas CARPi <nico-git@deltablot.email>
                       * @copyright 2012 Nicolas CARPi
                       * @see https://www.elabftw.net Official website
                       * @license AGPL-3.0
                      Severity: Minor
                      Found in src/ts/team.ts - About 2 hrs to fix

                        Method create has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function create(int $template = -1, array $tags = array()): int
                            {
                                $Templates = new Templates($this->Users);
                                $Teams = new Teams($this->Users);
                                $teamConfigArr = $Teams->readOne();
                        Severity: Major
                        Found in src/models/Experiments.php - About 2 hrs to fix

                          File Apiv2Controller.php has 283 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          
                          /**
                           * @author Nicolas CARPi <nico-git@deltablot.email>
                           * @copyright 2022 Nicolas CARPi
                          Severity: Minor
                          Found in src/controllers/Apiv2Controller.php - About 2 hrs to fix

                            Function execFile has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function execFile(string $filename, bool $force = false): int
                                {
                                    if ($this->output !== null) {
                                        // add two for the spaces around
                                        $len = strlen($filename) + 2;
                            Severity: Minor
                            Found in src/classes/Sql.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 importFile has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function importFile(array $file): void
                                {
                                    // note: path transversal vuln is detected and handled by flysystem
                                    $filepath = $this->tmpPath . '/' . basename($this->root) . '/' . $file['@id'];
                                    // checksum is mandatory for import
                            Severity: Minor
                            Found in src/Import/Eln.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

                            Method getTwig has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function getTwig(bool $debug): Environment
                                {
                                    // load templates
                                    $loader = new FilesystemLoader(dirname(__DIR__, 2) . '/src/templates');
                            
                            
                            Severity: Major
                            Found in src/traits/TwigTrait.php - About 2 hrs to fix

                              Function setup has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  setup: (editor: Editor): void => {
                                    // holds the timer setTimeout function
                                    let typingTimer;
                                    // make the edges round
                                    editor.on('init', () => editor.getContainer().className += ' rounded');
                              Severity: Major
                              Found in src/ts/tinymce.ts - About 2 hrs to fix

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

                                    public function visitTimestampField(TimestampField $timestampField, VisitorParameters $parameters): WhereCollector
                                    {
                                        $query = '';
                                        $bindValues = array();
                                
                                
                                Severity: Major
                                Found in src/services/advancedSearchQuery/visitors/QueryBuilderVisitor.php - About 2 hrs to fix

                                  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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language