Add unused arg validation rule

This commit is contained in:
Brahim Hadriche committed 2023-12-22 11:42:51 -05:00
1 parent 192401c847
commit 8f1d3778d8
11 files changed
+32 -23

No files matched your search

+9
View File
@@ -27,6 +27,15 @@
"regex": "@\\.\\w+\\(invalid\\)",
"regexFlags": "ig",
"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": [
@@ -21,7 +21,7 @@ function PushScreen(node as object)
FocusTopScreen(invalid)
end function
function PopScreen(unused as dynamic)
function PopScreen(_unused as dynamic)
childCount = m.stack.getChildCount()
if childCount > 1
m.stack.removeChildIndex(childCount - 1)
@@ -29,7 +29,7 @@ function PopScreen(unused as dynamic)
end if
end function
function FocusTopScreen(unused as dynamic)
function FocusTopScreen(_unused as dynamic)
childCount = m.stack.getChildCount()
topScreen = m.stack.getChild(childCount - 1)
NodeSetFocus(topScreen, true)
@@ -56,7 +56,7 @@ function WrapWithIndexField(node as object) as object
end function
' 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)
items = []
for each node in queueNodes
@@ -92,13 +92,13 @@ function GetQueue(unused as dynamic) as object
}
end function
function Clear(unused as dynamic)
function Clear(_unused as dynamic)
m.content.removeChildrenIndex(m.content.getChildCount(), 0)
m.top.index = -1
m.top.playlistIndex = -1
end function
function PlayNextItem(unused as dynamic) as boolean
function PlayNextItem(_unused as dynamic) as boolean
childCount = m.content.getChildCount()
if childCount = 0
return false
@@ -235,6 +235,6 @@ function watchedVideosContain(videoId as string) as boolean
return m.watchedVideos.Contains(videoId)
end function
function watchedVideosClear(unused as dynamic)
function watchedVideosClear(_unused as dynamic)
m.watchedVideos = new RingBuffer(100)
end function
@@ -41,7 +41,7 @@ function OnVisibleChange()
end if
end function
function Refresh(unused as dynamic)
function Refresh(_unused as dynamic)
m.isDirty = true
OnBookmarksChange()
end function
@@ -7,23 +7,23 @@ function Init()
m.service = new ApplicationInfo(m.top)
end function
function GetAppInfo(unused as dynamic) as object
function GetAppInfo(_unused as dynamic) as object
return m.service.GetAppInfo()
end function
function GetDeviceInfo(unused as dynamic) as object
function GetDeviceInfo(_unused as dynamic) as object
return m.service.GetDeviceInfo()
end function
function GetUserCountryCode(unused as dynamic) as string
function GetUserCountryCode(_unused as dynamic) as string
return m.service.GetUserCountryCode()
end function
function GetLocalIpAddress(unused as dynamic) as dynamic
function GetLocalIpAddress(_unused as dynamic) as dynamic
return m.service.GetLocalIpAddress()
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)
return m.top.lib_version_latest
end if
@@ -8,11 +8,11 @@ function Init()
m.top.authToken = m.service.GetAuthToken()
end function
function GetCurrentInstance(unused as dynamic) as string
function GetCurrentInstance(_unused as dynamic) as string
return m.service.GetInstance()
end function
function GetAuthorizeTokenLink(unused as dynamic) as dynamic
function GetAuthorizeTokenLink(_unused as dynamic) as dynamic
return m.service.GetAuthorizeTokenLink()
end function
@@ -141,7 +141,7 @@ function ApplyToUserPreferences(userPrefs as object, model as object) as boolean
return isDirty
end function
function GetUserPreferences(unused as dynamic) as object
function GetUserPreferences(_unused as dynamic) as object
userPrefs = {}
prefsFields = m.top.preferenceFields
for each key in prefsFields
@@ -162,7 +162,7 @@ function ApplyUserPreferences(preferences as object) as void
SaveUserPreferencesToRegistry()
end function
function ClearUserPreferences(unused as dynamic) as void
function ClearUserPreferences(_unused as dynamic) as void
userPrefs = {}
ApplyDefaultsToUserPreferences(userPrefs)
ApplyUserPreferences(userPrefs)
@@ -116,7 +116,7 @@ function MarkVideoWatched(videoId as string)
end if
end function
function Close(unused as dynamic)
function Close(_unused as dynamic)
m.top.control = "stop"
m.top.content = invalid
parent = m.top.getParent()
@@ -17,7 +17,7 @@ function Init()
m.top.serverName = "Playlet Web Server"
end function
function GetServerAddress(unused as dynamic) as dynamic
function GetServerAddress(_unused as dynamic) as dynamic
port = m.top.port
ip = m.top.applicationInfo@.GetLocalIpAddress()
if StringUtils.IsNullOrEmpty(ip)
@@ -6,7 +6,7 @@ function Init()
m.top.functionName = "WebServerLoop"
end function
function StartServer(unused as dynamic) as boolean
function StartServer(_unused as dynamic) as boolean
if m.top.isRunning = true
return true
end if
@@ -15,7 +15,7 @@ function StartServer(unused as dynamic) as boolean
return true
end function
function StopServer(unused as dynamic) as void
function StopServer(_unused as dynamic) as void
if m.top.isRunning = false
return
end if
@@ -23,7 +23,7 @@ function AutoBindSceneGraph() as void
end 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
bindings = node.bindings
if bindings = invalid
@@ -97,7 +97,7 @@ end function
' Create scoped fields (m.fieldName) for all fields in this node
' To be called after BindNodeFieldsAndProps
function BindScopeFields(unused as dynamic)
function BindScopeFields(_unused as dynamic)
types = m.top.getFieldTypes()
for each key in types
if m.DoesExist(key)
@@ -114,7 +114,7 @@ function BindScopeFields(unused as dynamic)
end function
' 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()
BindNodeFieldsAndProps(invalid)
BindScopeFields(invalid)