roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (Jira)" <j...@apache.org>
Subject [jira] [Work logged] (ROL-2157) Variables should be declared explicitly in Custom JS code
Date Thu, 19 Dec 2019 11:37:00 GMT

     [ https://issues.apache.org/jira/browse/ROL-2157?focusedWorklogId=361442&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-361442
]

ASF GitHub Bot logged work on ROL-2157:
---------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Dec/19 11:36
            Start Date: 19/Dec/19 11:36
    Worklog Time Spent: 10m 
      Work Description: adityasharma7 commented on pull request #52: Fixed: Variables should
be declared explicitly in Custom JS code (ROL-2157)
URL: https://github.com/apache/roller/pull/52
 
 
   
 
----------------------------------------------------------------
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:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 361442)
    Time Spent: 0.5h  (was: 20m)

> 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: 0.5h
>  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)

Mime
View raw message