[
https://issues.apache.org/jira/browse/ROL-2157?focusedWorklogId=337823&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-337823
]
ASF GitHub Bot logged work on ROL-2157:
---------------------------------------
Author: ASF GitHub Bot
Created on: 03/Nov/19 13:24
Start Date: 03/Nov/19 13:24
Worklog Time Spent: 10m
Work Description: adityasharma7 commented on pull request #46: Fixed:
Variables should be declared explicitly in Custom JS code (ROL-2157)
URL: https://github.com/apache/roller/pull/46
Pattern is identified and reported at sonacloud.io as Blocker
JavaScript variable scope can be particularly difficult to understand and
get right. The situation gets even worse when you consider the accidental
creation of global variables, which is what happens when you declare a variable
inside a function or the for clause of a for-loop without using the let, const
or var keywords.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 337823)
Remaining Estimate: 0h
Time Spent: 10m
> Variables should be declared explicitly in Custom JS code
> ---------------------------------------------------------
>
> Key: ROL-2157
> URL: https://issues.apache.org/jira/browse/ROL-2157
> Project: Apache Roller
> Issue Type: Bug
> Reporter: Aditya Sharma
> Assignee: Aditya Sharma
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Pattern is identified and reported at sonacloud.io as Blocker
> JavaScript variable scope can be particularly difficult to understand and get
> right. The situation gets even worse when you consider the _accidental_
> creation of global variables, which is what happens when you declare a
> variable inside a function or the {{for}} clause of a for-loop without using
> the {{let}}, {{const}} or {{var}} keywords.
> {{let}} and {{const}} were introduced in ECMAScript 2015, and are now the
> preferred keywords for variable declaration.
> Noncompliant Code Example
>
> {code:java}
> function f(){
> i = 1; // Noncompliant; i is global
> for (j = 0; j < array.length; j++) { // Noncompliant; j is global now too
> // ...
> }
> }
> {code}
>
> Compliant Solution
>
> {code:java}
> function f(){
> var i = 1;
> for (let j = 0; j < array.length; j++) {
> // ...
> }
> }
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)