This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 236674 - Detect possibly useless strings (by hint)
Summary: Detect possibly useless strings (by hint)
Status: REOPENED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3.1
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-03 01:05 UTC by sergioabreu
Modified: 2013-10-05 17:54 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sergioabreu 2013-10-03 01:05:43 UTC
If you enter a multiline string and closes it with a semicolon (;) and accidentally you add a new string one line below, Netbeans do not detect that the string entered there has no meaning as a programming line. I use PHP netbeans, but I don't know if this bug affects the other Netbeans families.

Code example:

$s = "blablabla" .
     "nenene" .
     "here I will cause the bug" ; /* <-- not a dot, ending the string */
     "This line was added thinking the line above had a dot after it" ;

// Netbeans shoud mark the line above as an error, since there is no attribution to the string.
Comment 1 Ondrej Brejla 2013-10-03 11:35:22 UTC
This is absolutely valid PHP snippet. It can be run without any parsing/other error.
Comment 2 sergioabreu 2013-10-05 10:17:41 UTC
OK, maybe I should change the title of the bug presented.
Netbeans uses to warn users of several less important problems in code.
In this case, ALTHOUGH it is an "absolute valid PHP snippet", you should agree that this snippet is useless in the code.

So I suggest that Netbeans shows the yellow warning icon in that line, telling that that string is not being doing anything in the code, since it:

* was not attribute to any variable.
* was not concatenated to anything.
* there is no echo, print, etc showing it.

So, if it is useless in the code - doesn't matter if the syntax is allowed or not by PHP, a good IDE should indicate a possible mistake of the programmer, in this case the concatenation was accidentally closed one line above.

Consider taking it as a feature. This would upgrade the Netbeans quality in this specific issue.

Regards.

Sergio
Comment 3 Ondrej Brejla 2013-10-05 17:12:10 UTC
It's definitely not a defect. If you want to be warned to valid syntax, it's an enhancement for a new hint.
Comment 4 sergioabreu 2013-10-05 17:54:29 UTC
Sorry for my typos, and thanks for the attention.
The situation I showed in my first post makes me believe that the non existence of this inteligence can cause undesirable results for the programmer.
In my first post, I showed an example in which the intention was to concatenate a string in a multiline sintax, and the introdution of ';' instead of '.' at the end of a line puts the programmer in a badly and false state of correctness since the line after ';' will NOT be concatenated.
Regards.