Comments (3)
Reading the rule description in Frédéric Bordage's book, it is specifically targeted to PHP !
The rule should check if a string use double quotes without having variables in it.
The rule has no meanings in JS (doesn't matter) nor Rust / Java (different meaning)
In the future this could also apply to posix shell scripts too
from ecocode.
Concerning PHP, this might be the opportunity for a PHP-specific rule: don't use double quotes if you don't need the string to be interpreted.
Basically, if a string is interpreted, it will replace variables, beginning with a $
(e.g. "My name is $userName"
). If there is no variable, asking PHP to interpret it seems to be redundant. Some checks would be required before deciding to make:
- Does a similar rule already exist in SonarQube? (a quick lookup through Sonarcloud rules seems to indicate that no, but a more thorough check would be welcome)
- Is there an optimization mechanism I don't know about that will prevent PHP from needlessly interpreting a String?
from ecocode.
True, I didn't read the book again. In JS/TS, it's mainly a style issue. In PHP, it does have an impact.
from ecocode.
Related Issues (20)
- License issue HOT 6
- UnnecessarilyAssignValuesToVariables NullPointerException HOT 1
- Documentation of Java backend rules HOT 1
- The rule "The variable value is not assigned" (JAVA) can report false positives. HOT 1
- Merge RTE code HOT 2
- No versions available for org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0) within specified range HOT 2
- Can't build CodeNarc HOT 6
- Quality gates and Quality profiles not visible HOT 2
- Is it possible to add "eco-conception" tag on existing built-in rules ? HOT 6
- [Java plugin] Compilation error with jdk 1.8 compliance HOT 4
- Migration compilation to Java 11 HOT 5
- Crash au lancement du container sonar HOT 1
- codenarc 2.2.3 referenced but not available on Maven central HOT 10
- Need precisions about JAVA S53 rule HOT 7
- Quelques questions HOT 1
- Dependance Maven codenarc inconnue (v2.2.1) HOT 5
- "Using strings as arguments to SetTimeout() and setInterval()" rule is maybe only available with js/ts HOT 1
- [Sonarqube Server] Integration incompatible between v9.4-community and php-plugin HOT 3
- Rename parent folder following maven convention HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecocode.