Travis CI error

Hi all. I am trying to create a pull request but I get an error on build:

1) CodingPhpTest::testPHP Found non escaped string in building of a sql request (case 3) in expedition/card.php: $sql .= ' AND obj.fk_' . $origin - Bad. Failed asserting that false is true.

and the line in question is $sql .= ' AND obj.fk_' . $origin . ' = ' . ((int)$origin_id);

The reason for this error is that I am using a single quotes instead of double quotes. All code style inspection in PHP IDE’s suggest replacing double quotes with single quotes.

How the above error can be fixed when using single quotes?

You probably use the wrong codesniffer ruleset in your IDE.
Dolibarr uses a dedicated ruleset found here: dev/setup/codesniffer

I don’t have it installed and I’m using the built-in PHPStorm code inspection. Guess I have to change this :slight_smile: . Is there a guide for developers on how to setup the IDE or just look at dev/install for what to do?

1 Like

I’ve checked the suggested code settings, but there are a few more things I’d like to ask.

As said, I am using PHPStorm as IDE. To use the “squizlabs/php_codesniffer” libraries, I need to rename “conf.json.disabled” to “config.json” and run composer update, and there are a few issues I’ve met:

  1. composer.json and composer.lock are not added to .gitignore by default

  2. The ignore of “htdocs/include” does not work for me, as they are added without a backslash at the beginning i.e.

  • when in .gitignore I have “htdocs/includes/squizlabs/” this is ignored and Git tries to commit the files in this folder
  • when in .gitignore I have “/htdocs/includes/squizlabs/” everything works fine and the folder is ignored during commit
    Not sure if this is IDE related issue or OS (Windows) one.

On the other hand, why not add “/includes” to “/htdocs/.gitignore” by default in Git repo?