Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN falsely indicated in CFM files with <cfinclude> #345

Closed
mpaluchowski opened this issue Jul 12, 2017 · 5 comments
Assignees
Milestone

Comments

@mpaluchowski
Copy link
Contributor

This requires the following 2 files to show:

reqularDesign.cfm

<cfinclude template="regularDesignHeader.cfm">

regularDesignHeader.cfm

<cfset StructKeyExists(quickInfoData, 'companyName') AND len(#quickInfoData['companyName']#) gt 0>
<cfset StructKeyExists(quickInfoData, 'companyName') AND len(#quickInfoData['companyName']#) gt 0>
<cfset StructKeyExists(quickInfoData, 'companyName') AND len(#quickInfoData['companyName']#) gt 0>

and the resulting XML will contain:

<issue severity="WARNING" id="GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN" message="GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN" category="CFLint" abbrev="GL">
  <location file="C:\Inbox\cflint-test\.\regularDesign.cfm" fileName="regularDesign.cfm" function="" column="71" line="2" message="Literal companyName occurs several times in one or more files. Consider giving it a name and not hard coding values." variable="companyName">
    <Expression><![CDATA['companyName']]></Expression>
  </location>
</issue>
<issue severity="WARNING" id="GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN" message="GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN" category="CFLint" abbrev="GL">
  <location file="C:\Inbox\cflint-test\.\regularDesign.cfm" fileName="regularDesign.cfm" function="" column="33" line="3" message="Literal companyName occurs several times in one or more files. Consider giving it a name and not hard coding values." variable="companyName">
    <Expression><![CDATA['companyName']]></Expression>
  </location>
</issue>
<issue severity="WARNING" id="GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN" message="GLOBAL_LITERAL_VALUE_USED_TOO_OFTEN" category="CFLint" abbrev="GL">
  <location file="C:\Inbox\cflint-test\.\regularDesign.cfm" fileName="regularDesign.cfm" function="" column="71" line="3" message="Literal companyName occurs several times in one or more files. Consider giving it a name and not hard coding values." variable="companyName">
    <Expression><![CDATA['companyName']]></Expression>
  </location>
</issue>

Even though regularDesign.cfm contains only 1 line and doesn't mention companyName at all. The issue appears clearly because CFLint interprets the <cfinclude> and treats regularDesign.cfm as if it actually included regularDesignHeader.cfm.

@ryaneberly
Copy link
Contributor

Good catch. I think.... the included file should be processed in terms of variable use, but should not generate any messages. What do you think?

@ryaneberly ryaneberly self-assigned this Jul 12, 2017
@mpaluchowski
Copy link
Contributor Author

Yes, if you're tracking variable use across includes, then the parent file shouldn't trigger warnings when it doesn't have the reported literal.

@ryaneberly ryaneberly added this to the 1.2.0 milestone Jul 13, 2017
ryaneberly added a commit that referenced this issue Jul 13, 2017
suppressed message reporting when included files are processed.
@mpaluchowski
Copy link
Contributor Author

I confirm, this one looks fixed now.

@TheRealAgentK
Copy link
Collaborator

This fix actually dropped the number of reported CFQUERYPARAM_REQ instances in one of my test runs from 21 to 8 (cfc with included cfm files) - looked properly into it and tracked each instance and I can confirm that the new (and way better) behaviour is working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@TheRealAgentK @mpaluchowski @ryaneberly and others