Add unused arg validation rule
This commit is contained in:
1 parent
192401c847
commit
8f1d3778d8
11 files changed
+32
-23
No files matched your search
@@ -27,6 +27,15 @@
|
|||||||
"regex": "@\\.\\w+\\(invalid\\)",
|
"regex": "@\\.\\w+\\(invalid\\)",
|
||||||
"regexFlags": "ig",
|
"regexFlags": "ig",
|
||||||
"message": "the arg invalid in @.func(invalid) is not needed. Just use @.func() instead."
|
"message": "the arg invalid in @.func(invalid) is not needed. Just use @.func() instead."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Tagging unused variables (Available since Roku OS 11.0) – Variables can explicitly
|
||||||
|
// be marked as unused by prepending an underscore to the value (for example, sub myTask(_x)).
|
||||||
|
// https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#types
|
||||||
|
"code": "UNUSED_ARG_STARTS_WITH_UNDERSCORE",
|
||||||
|
"regex": "\\b(?!_unused)unused\\b",
|
||||||
|
"regexFlags": "ig",
|
||||||
|
"message": "unused args should start with _ (e.g. _unused)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ function PushScreen(node as object)
|
|||||||
FocusTopScreen(invalid)
|
FocusTopScreen(invalid)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function PopScreen(unused as dynamic)
|
function PopScreen(_unused as dynamic)
|
||||||
childCount = m.stack.getChildCount()
|
childCount = m.stack.getChildCount()
|
||||||
if childCount > 1
|
if childCount > 1
|
||||||
m.stack.removeChildIndex(childCount - 1)
|
m.stack.removeChildIndex(childCount - 1)
|
||||||
@@ -29,7 +29,7 @@ function PopScreen(unused as dynamic)
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function FocusTopScreen(unused as dynamic)
|
function FocusTopScreen(_unused as dynamic)
|
||||||
childCount = m.stack.getChildCount()
|
childCount = m.stack.getChildCount()
|
||||||
topScreen = m.stack.getChild(childCount - 1)
|
topScreen = m.stack.getChild(childCount - 1)
|
||||||
NodeSetFocus(topScreen, true)
|
NodeSetFocus(topScreen, true)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ function WrapWithIndexField(node as object) as object
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
' TODO:P0 better model of the queue (Now playing, etc)
|
' TODO:P0 better model of the queue (Now playing, etc)
|
||||||
function GetQueue(unused as dynamic) as object
|
function GetQueue(_unused as dynamic) as object
|
||||||
queueNodes = m.content.getChildren(-1, 0)
|
queueNodes = m.content.getChildren(-1, 0)
|
||||||
items = []
|
items = []
|
||||||
for each node in queueNodes
|
for each node in queueNodes
|
||||||
@@ -92,13 +92,13 @@ function GetQueue(unused as dynamic) as object
|
|||||||
}
|
}
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function Clear(unused as dynamic)
|
function Clear(_unused as dynamic)
|
||||||
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
|
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
|
||||||
m.top.index = -1
|
m.top.index = -1
|
||||||
m.top.playlistIndex = -1
|
m.top.playlistIndex = -1
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function PlayNextItem(unused as dynamic) as boolean
|
function PlayNextItem(_unused as dynamic) as boolean
|
||||||
childCount = m.content.getChildCount()
|
childCount = m.content.getChildCount()
|
||||||
if childCount = 0
|
if childCount = 0
|
||||||
return false
|
return false
|
||||||
@@ -235,6 +235,6 @@ function watchedVideosContain(videoId as string) as boolean
|
|||||||
return m.watchedVideos.Contains(videoId)
|
return m.watchedVideos.Contains(videoId)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function watchedVideosClear(unused as dynamic)
|
function watchedVideosClear(_unused as dynamic)
|
||||||
m.watchedVideos = new RingBuffer(100)
|
m.watchedVideos = new RingBuffer(100)
|
||||||
end function
|
end function
|
||||||
@@ -41,7 +41,7 @@ function OnVisibleChange()
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function Refresh(unused as dynamic)
|
function Refresh(_unused as dynamic)
|
||||||
m.isDirty = true
|
m.isDirty = true
|
||||||
OnBookmarksChange()
|
OnBookmarksChange()
|
||||||
end function
|
end function
|
||||||
|
|||||||
@@ -7,23 +7,23 @@ function Init()
|
|||||||
m.service = new ApplicationInfo(m.top)
|
m.service = new ApplicationInfo(m.top)
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetAppInfo(unused as dynamic) as object
|
function GetAppInfo(_unused as dynamic) as object
|
||||||
return m.service.GetAppInfo()
|
return m.service.GetAppInfo()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetDeviceInfo(unused as dynamic) as object
|
function GetDeviceInfo(_unused as dynamic) as object
|
||||||
return m.service.GetDeviceInfo()
|
return m.service.GetDeviceInfo()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetUserCountryCode(unused as dynamic) as string
|
function GetUserCountryCode(_unused as dynamic) as string
|
||||||
return m.service.GetUserCountryCode()
|
return m.service.GetUserCountryCode()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetLocalIpAddress(unused as dynamic) as dynamic
|
function GetLocalIpAddress(_unused as dynamic) as dynamic
|
||||||
return m.service.GetLocalIpAddress()
|
return m.service.GetLocalIpAddress()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetLatestPlayletLibVersion(unused as dynamic) as dynamic
|
function GetLatestPlayletLibVersion(_unused as dynamic) as dynamic
|
||||||
if not StringUtils.IsNullOrEmpty(m.top.lib_version_latest)
|
if not StringUtils.IsNullOrEmpty(m.top.lib_version_latest)
|
||||||
return m.top.lib_version_latest
|
return m.top.lib_version_latest
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ function Init()
|
|||||||
m.top.authToken = m.service.GetAuthToken()
|
m.top.authToken = m.service.GetAuthToken()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetCurrentInstance(unused as dynamic) as string
|
function GetCurrentInstance(_unused as dynamic) as string
|
||||||
return m.service.GetInstance()
|
return m.service.GetInstance()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetAuthorizeTokenLink(unused as dynamic) as dynamic
|
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
|
||||||
return m.service.GetAuthorizeTokenLink()
|
return m.service.GetAuthorizeTokenLink()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ function ApplyToUserPreferences(userPrefs as object, model as object) as boolean
|
|||||||
return isDirty
|
return isDirty
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetUserPreferences(unused as dynamic) as object
|
function GetUserPreferences(_unused as dynamic) as object
|
||||||
userPrefs = {}
|
userPrefs = {}
|
||||||
prefsFields = m.top.preferenceFields
|
prefsFields = m.top.preferenceFields
|
||||||
for each key in prefsFields
|
for each key in prefsFields
|
||||||
@@ -162,7 +162,7 @@ function ApplyUserPreferences(preferences as object) as void
|
|||||||
SaveUserPreferencesToRegistry()
|
SaveUserPreferencesToRegistry()
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ClearUserPreferences(unused as dynamic) as void
|
function ClearUserPreferences(_unused as dynamic) as void
|
||||||
userPrefs = {}
|
userPrefs = {}
|
||||||
ApplyDefaultsToUserPreferences(userPrefs)
|
ApplyDefaultsToUserPreferences(userPrefs)
|
||||||
ApplyUserPreferences(userPrefs)
|
ApplyUserPreferences(userPrefs)
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ function MarkVideoWatched(videoId as string)
|
|||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function Close(unused as dynamic)
|
function Close(_unused as dynamic)
|
||||||
m.top.control = "stop"
|
m.top.control = "stop"
|
||||||
m.top.content = invalid
|
m.top.content = invalid
|
||||||
parent = m.top.getParent()
|
parent = m.top.getParent()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function Init()
|
|||||||
m.top.serverName = "Playlet Web Server"
|
m.top.serverName = "Playlet Web Server"
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetServerAddress(unused as dynamic) as dynamic
|
function GetServerAddress(_unused as dynamic) as dynamic
|
||||||
port = m.top.port
|
port = m.top.port
|
||||||
ip = m.top.applicationInfo@.GetLocalIpAddress()
|
ip = m.top.applicationInfo@.GetLocalIpAddress()
|
||||||
if StringUtils.IsNullOrEmpty(ip)
|
if StringUtils.IsNullOrEmpty(ip)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ function Init()
|
|||||||
m.top.functionName = "WebServerLoop"
|
m.top.functionName = "WebServerLoop"
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function StartServer(unused as dynamic) as boolean
|
function StartServer(_unused as dynamic) as boolean
|
||||||
if m.top.isRunning = true
|
if m.top.isRunning = true
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
@@ -15,7 +15,7 @@ function StartServer(unused as dynamic) as boolean
|
|||||||
return true
|
return true
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function StopServer(unused as dynamic) as void
|
function StopServer(_unused as dynamic) as void
|
||||||
if m.top.isRunning = false
|
if m.top.isRunning = false
|
||||||
return
|
return
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function AutoBindSceneGraph() as void
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
' Bind the node fields, to be called with interface function
|
' Bind the node fields, to be called with interface function
|
||||||
function BindNodeFieldsAndProps(unused as dynamic) as void
|
function BindNodeFieldsAndProps(_unused as dynamic) as void
|
||||||
node = m.top
|
node = m.top
|
||||||
bindings = node.bindings
|
bindings = node.bindings
|
||||||
if bindings = invalid
|
if bindings = invalid
|
||||||
@@ -97,7 +97,7 @@ end function
|
|||||||
|
|
||||||
' Create scoped fields (m.fieldName) for all fields in this node
|
' Create scoped fields (m.fieldName) for all fields in this node
|
||||||
' To be called after BindNodeFieldsAndProps
|
' To be called after BindNodeFieldsAndProps
|
||||||
function BindScopeFields(unused as dynamic)
|
function BindScopeFields(_unused as dynamic)
|
||||||
types = m.top.getFieldTypes()
|
types = m.top.getFieldTypes()
|
||||||
for each key in types
|
for each key in types
|
||||||
if m.DoesExist(key)
|
if m.DoesExist(key)
|
||||||
@@ -114,7 +114,7 @@ function BindScopeFields(unused as dynamic)
|
|||||||
end function
|
end function
|
||||||
|
|
||||||
' Bind a single node. This for nodes created dynamically, and all its dependencies are expected to be bound already
|
' Bind a single node. This for nodes created dynamically, and all its dependencies are expected to be bound already
|
||||||
function BindNode(unused as dynamic)
|
function BindNode(_unused as dynamic)
|
||||||
RemoveNodeFromGlobalAutoBind()
|
RemoveNodeFromGlobalAutoBind()
|
||||||
BindNodeFieldsAndProps(invalid)
|
BindNodeFieldsAndProps(invalid)
|
||||||
BindScopeFields(invalid)
|
BindScopeFields(invalid)
|
||||||
|
|||||||
Reference in new issue
Block a user