Bug #4151
make databaseMode usage safer in rpt_file_list
100%
History
#1 Updated by Vladimir Tsichevski almost 7 years ago
If the databaseMode="true" is used when running the reports/rpt_file_list report, and not a *.schema AST source is passed:
- No error message is generated;
- The output file is expected to be empty, but it contains a word
nullinstead.
Example:
$ pushd p2j/ $ bzr revno 11324 $ popd $ java -classpath $P2J_HOME/p2j/build/lib/p2j.jar com.goldencode.p2j.pattern.PatternEngine databaseMode="true" condition="'true'" reports/rpt_file_list ./abl/ hello_world.p.ast ./abl/hello_world.p Elapsed job time: 00:00:00.281 $ cat matched_filename_list.txt null $
Note: the condition option must evaluate to true for the source file to reproduce this situation.
#2 Updated by Greg Shah almost 7 years ago
There are 2 sources of "database" ASTs:
.dffiles which are the schemata for databases- static temp-table definitions in 4GL source code
In both cases these will become .schema AST files, which database semantics instead of code semantics.
To get a meaningful schema name, for these database ASTs we use getNoteString("srcfile"). When this returns null you get the bad behavior you have found.
Please note that I suspect that using getNoteString("srcfile") will not work for some conditions even if it is on a database AST. Please check at which nodes in a .schema AST, the "srcfile" annotation is valid. Probably just at the root node, I suspect. This is another bug that should be resolved in this task.
#3 Updated by Vladimir Tsichevski almost 7 years ago
- Status changed from New to WIP
#4 Updated by Vladimir Tsichevski almost 7 years ago
The right thing will be to change the script logic as follows:
- if the "srcfile" annotation is defined for a node, use this annotation value;
- otherwise use the source file name.
Note: this also completely eliminates the need for the "databaseMode" option. If someone has added the "srcfile" annotation, then he meant a reference to the source file, all other considerations unimportant.
#5 Updated by Greg Shah almost 7 years ago
That sounds reasonable.
Eric: You put in the databaseMode. What do you think?
#6 Updated by Greg Shah almost 7 years ago
It also may make sense to check for srcfile on the root node. If it exists there, use it else use file.
#7 Updated by Vladimir Tsichevski almost 7 years ago
It also may make sense to check for srcfile on the root node. If it exists there, use it else use file.
Agreed. Otherwise special care is taken now to process only the first match. Checking only the root node would further simplify the code.
But first need to check if the root node is always the one which is annotated with "srcfile".
#8 Updated by Vladimir Tsichevski almost 7 years ago
The changes are as follows:
- only the root AST node is now tested for the condition;
- the databaseMode comamnd-line option is not used and was eliminated;
- if the root node is annotated with the "srcfile", the annotation value is used instead of the file name;
- the 'null' value now never goes to the output file.
The changes were committed to the 4151a branch, rev.11327.
#9 Updated by Vladimir Tsichevski almost 7 years ago
- % Done changed from 0 to 50
- Status changed from WIP to Review
#10 Updated by Eric Faulhaber almost 7 years ago
- Start date deleted (
07/22/2019)
Greg Shah wrote:
Eric: You put in the
databaseMode. What do you think?
I'm pretty sure I've never touched this file. The changes seem ok to me, given the above discussion. However, AFAIR, with the introduction of the code analytics feature set, this rule set is no longer used.
#11 Updated by Greg Shah almost 7 years ago
Code Review Task Branch 4151a Revision 11327
I'm good with the changes.
#12 Updated by Greg Shah almost 7 years ago
AFAIR, with the introduction of the code analytics feature set, this rule set is no longer used.
This ruleset and also the simple search ruleset are still useful. If you are trying to get a quick list of matches or files that match, then these two rulesets can be used from the command line using the PatternEngine and directly hitting ASTs. This can be a useful way to get some answers, especially on a big project where the running of analytics may take some time.
#13 Updated by Greg Shah almost 7 years ago
Please merge 4151a to trunk.
You will need to make some edits to the documentation as well, but make sure that it is clear that the changes only affect FWD v3.3 and later. For the earlier FWD versions, you have some clarifications to make as discussed separately.
#14 Updated by Vladimir Tsichevski almost 7 years ago
- % Done changed from 50 to 60
The task branch 4151a has been committed into the trunk as bzr revision 11327.
#15 Updated by Vladimir Tsichevski almost 7 years ago
- % Done changed from 60 to 100
The page https://proj.goldencode.com/projects/p2j/wiki/Chapter_10_Reporting was updated to reflect the changes in the code.
#16 Updated by Greg Shah almost 7 years ago
Note: Only the root AST node is tested for the condition in the condition parameter in this very report in FWD v.3.3 and later versions.
Actually, I missed this part of the change. Sorry, I should have caught this on review. This is not correct behavior. We should not limit the condition to the root node. We only want to limit the reading of the srcfile annotation to that node. Only matching the condition at the root excludes most of the use cases for this rule set.
Please see task branch 4069a revision 11353 where I have made the appropriate changes. Please test it to confirm it works.
#17 Updated by Vladimir Tsichevski almost 7 years ago
Greg Shah wrote:
Please see task branch 4069a revision 11353 where I have made the appropriate changes. Please test it to confirm it works.
I cannot get the revision 11353, and the revision 11352 contains no changes:
bzr co ~/secure/code/p2j_repo/p2j/active/4069a pushd 4069a bzr revno 11352
#18 Updated by Greg Shah almost 7 years ago
Sorry, I had not pushed my changes. Try bzr update now.
#19 Updated by Vladimir Tsichevski almost 7 years ago
- File 4069a.diff
added
The report in 4069a does not work for two reasons:
- there is not such property as
root. There is a functionboolean root(), but it just test the current node; - the name of the annotation is
srcname, not thesrcfile.
I have the fix attached to this note.
#20 Updated by Vladimir Tsichevski almost 7 years ago
- File 4069.diff
added
- the name of the annotation is
srcname, not thesrcfile.
The srcfile is the right name indeed. Please ignore the quoted sentence in the previous note.
The fixed diff file included.
#21 Updated by Greg Shah over 6 years ago
- Status changed from Review to Closed
A slightly modified version of this fix is checked in to 4069a revision 11433. I'm closing this task.