From 6b36a1696ec0ab63ff1fc9588b0f5eeabf987097 Mon Sep 17 00:00:00 2001 From: Deyan Dobromirov Date: Thu, 11 Jun 2020 18:24:38 +0300 Subject: [PATCH] Updated: GLua lint fixing syntax check --- .../workflows/glualint.json | 14 +++++----- .github/workflows/glualint.yml | 2 +- data/hooks/pre-commit.lua | 4 +-- data/workshop/key.txt | 6 +++- lua/autorun/trackassembly_init.lua | 28 ++++++++----------- lua/trackassembly/trackasmlib.lua | 6 ++-- .../gmod_tool/stools/trackassembly.lua | 5 ++-- 7 files changed, 31 insertions(+), 34 deletions(-) rename glualint.json => .github/workflows/glualint.json (69%) diff --git a/glualint.json b/.github/workflows/glualint.json similarity index 69% rename from glualint.json rename to .github/workflows/glualint.json index 3158589..5317545 100644 --- a/glualint.json +++ b/.github/workflows/glualint.json @@ -4,20 +4,20 @@ "lint_syntaxInconsistencies": true, "lint_deprecated": true, "lint_trailingWhitespace": true, - "lint_whitespaceStyle": true, + "lint_whitespaceStyle": false, "lint_beginnerMistakes": true, "lint_emptyBlocks": true, - "lint_shadowing": true, + "lint_shadowing": false, "lint_gotos": true, "lint_doubleNegations": true, - "lint_redundantIfStatements": true, - "lint_redundantParentheses": true, + "lint_redundantIfStatements": false, + "lint_redundantParentheses": false, "lint_duplicateTableKeys": true, "lint_profanity": true, - "lint_unusedVars": true, + "lint_unusedVars": false, "lint_unusedParameters": false, "lint_unusedLoopVars": false, - "lint_ignoreFiles": [], + "lint_ignoreFiles": ["data/hooks/pre-commit.lua", "lua/entities/gmod_wire_expression2/core/custom/trackasmlib_wire.lua"], "prettyprint_spaceAfterParens": false, "prettyprint_spaceAfterBrackets": false, @@ -27,5 +27,5 @@ "prettyprint_semicolons": false, "prettyprint_cStyle": false, "prettyprint_rejectInvalidCode": false, - "prettyprint_indentation": " " + "prettyprint_indentation": " " } diff --git a/.github/workflows/glualint.yml b/.github/workflows/glualint.yml index a948639..2169022 100644 --- a/.github/workflows/glualint.yml +++ b/.github/workflows/glualint.yml @@ -14,4 +14,4 @@ jobs: wget -O glualint.zip https://github.com/FPtje/GLuaFixer/releases/download/1.11.1/glualint-1.11.1-linux.zip unzip glualint.zip - name: Lint - run: ./glualint . + run: ./glualint --config .github/workflows/glualint.json diff --git a/data/hooks/pre-commit.lua b/data/hooks/pre-commit.lua index 6313577..c4415f0 100644 --- a/data/hooks/pre-commit.lua +++ b/data/hooks/pre-commit.lua @@ -14,7 +14,7 @@ function trim(s) return s:match("^%s*(.-)%s*$") end local sLog = tostring(arg[4]):gsub("\\","/") local fLog, sE = io.open(sLog,"a+") -if(fLog) then io.output(fLog) end +if(fLog) then io.output(fLog) else io.output("Error: "..sE) end io.write(fSta:format("START")) @@ -79,5 +79,3 @@ if(fLog) then fLog:flush() fLog:close() end - - diff --git a/data/workshop/key.txt b/data/workshop/key.txt index d717b7b..52fe152 100644 --- a/data/workshop/key.txt +++ b/data/workshop/key.txt @@ -1,2 +1,6 @@ .git -.svn \ No newline at end of file +.svn +.github +.gitattributes +.gitignore +data diff --git a/lua/autorun/trackassembly_init.lua b/lua/autorun/trackassembly_init.lua index e336e1d..9ef2d6e 100644 --- a/lua/autorun/trackassembly_init.lua +++ b/lua/autorun/trackassembly_init.lua @@ -75,7 +75,7 @@ local gtInitLogs = {"*Init", false, 0} ------ CONFIGURE ASMLIB ------ asmlib.InitBase("track","assembly") -asmlib.SetOpVar("TOOL_VERSION","7.611") +asmlib.SetOpVar("TOOL_VERSION","7.613") asmlib.SetIndexes("V" , "x", "y", "z") asmlib.SetIndexes("A" ,"pitch","yaw","roll") asmlib.SetIndexes("WV",1,2,3) @@ -181,8 +181,7 @@ local gsCbcHash = "_init" -- This keeps suffix related to the file gsVarName = asmlib.GetAsmConvar("maxtrmarg", "NAM") cvarsRemoveChangeCallback(gsVarName, gsVarName..gsCbcHash) cvarsAddChangeCallback(gsVarName, function(sVar, vOld, vNew) - local nM = (tonumber(vNew) or 0) - nM = ((nM > 0) and nM or 0) + local nM = (tonumber(vNew) or 0); nM = ((nM > 0) and nM or 0) asmlib.SetOpVar("TRACE_MARGIN", nM) end, gsVarName..gsCbcHash) @@ -432,11 +431,10 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) local scrW, scrH = surfaceScreenWidth(), surfaceScreenHeight() local actMonitor = asmlib.MakeScreen(0,0,scrW,scrH,conPalette,"GAME") if(not actMonitor) then asmlib.LogInstance("Invalid screen",gtArgsLogs); return nil end - local vBs = asmlib.NewXY(4,4) + local vBs, nR = asmlib.NewXY(4,4), (gnRatio-1) local nN = conWorkMode:GetSize() local nDr = asmlib.GetOpVar("DEG_RAD") local sM = asmlib.GetOpVar("MISS_NOAV") - local nR = (asmlib.GetOpVar("GOLDEN_RATIO")-1) local vCn = asmlib.NewXY(mathFloor(scrW/2),mathFloor(scrH/2)) -- Calculate dependent parameters local vFr = asmlib.NewXY(vCn.y*nR) -- Far radius vector @@ -498,9 +496,8 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) function(oPly,oCom,oArgs) gtArgsLogs[1] = "*OPEN_EXTERNDB" local scrW = surfaceScreenWidth() local scrH = surfaceScreenHeight() - local nRat = asmlib.GetOpVar("GOLDEN_RATIO") local sVer = asmlib.GetOpVar("TOOL_VERSION") - local xyPos, nAut = asmlib.NewXY(scrW/4,scrH/4), (nRat - 1) + local xyPos, nAut = asmlib.NewXY(scrW/4,scrH/4), (gnRatio - 1) local xyDsz, xyTmp = asmlib.NewXY(5,5), asmlib.NewXY() local xySiz = asmlib.NewXY(nAut * scrW, nAut * scrH) local pnFrame = vguiCreate("DFrame"); if(not IsValid(pnFrame)) then @@ -542,7 +539,7 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) xyPos.x, xyPos.y = xyDsz.x, xyDsz.y xySiz.x = (nW - 6 * xyDsz.x) xySiz.y = ((nH - 6 * xyDsz.y) - 52) - local wAct = mathFloor(((nRat - 1) / 6) * xySiz.x) + local wAct = mathFloor(((gnRatio - 1) / 6) * xySiz.x) local wUse = mathFloor(xySiz.x - wAct) local pnListView = vguiCreate("DListView") if(not IsValid(pnListView)) then pnFrame:Close() @@ -724,7 +721,6 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) ------ Screen resolution and configuration ------- local scrW = surfaceScreenWidth() local scrH = surfaceScreenHeight() - local nRatio = asmlib.GetOpVar("GOLDEN_RATIO") local sVersion = asmlib.GetOpVar("TOOL_VERSION") local xyZero = {x = 0, y = 20} -- The start location of left-top local xyDelta = {x = 10, y = 10} -- Distance between panels @@ -732,9 +728,9 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) local xyPos = {x = 0, y = 0} -- Current panel position local xyTmp = {x = 0, y = 0} -- Temporary coordinate ------------ Frame -------------- - xySiz.x = (scrW / nRatio) -- This defines the size of the frame + xySiz.x = (scrW / gnRatio) -- This defines the size of the frame xyPos.x, xyPos.y = (scrW / 4), (scrH / 4) - xySiz.y = mathFloor(xySiz.x / (1 + nRatio)) + xySiz.y = mathFloor(xySiz.x / (1 + gnRatio)) pnFrame:SetTitle(asmlib.GetPhrase("tool."..gsToolNameL..".pn_routine_hd").." "..oPly:Nick().." {"..sVersion.."}") pnFrame:SetVisible(true) pnFrame:SetDraggable(true) @@ -748,8 +744,8 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) end ------------ Button -------------- xyTmp.x, xyTmp.y = pnFrame:GetSize() - xySiz.x = (xyTmp.x / (8.5 * nRatio)) -- Display properly the name - xySiz.y = (xySiz.x / (1.5 * nRatio)) -- Used by combo-box and text-box + xySiz.x = (xyTmp.x / (8.5 * gnRatio)) -- Display properly the name + xySiz.y = (xySiz.x / (1.5 * gnRatio)) -- Used by combo-box and text-box xyPos.x = xyZero.x + xyDelta.x xyPos.y = xyZero.y + xyDelta.y local pnButton = vguiCreate("DButton") @@ -766,7 +762,7 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) xyPos.x, xyPos.y = pnButton:GetPos() xyTmp.x, xyTmp.y = pnButton:GetSize() xyPos.x = xyPos.x + xyTmp.x + xyDelta.x - xySiz.x, xySiz.y = (nRatio * xyTmp.x), xyTmp.y + xySiz.x, xySiz.y = (gnRatio * xyTmp.x), xyTmp.y local pnComboBox = vguiCreate("DComboBox") if(not IsValid(pnComboBox)) then pnFrame:Close() asmlib.LogInstance("Combo invalid",gtArgsLogs); return nil end @@ -788,7 +784,7 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) ------------ ModelPanel -------------- xyTmp.x, xyTmp.y = pnFrame:GetSize() xyPos.x, xyPos.y = pnComboBox:GetPos() - xySiz.x = (xyTmp.x / (1.9 * nRatio)) -- Display the model properly + xySiz.x = (xyTmp.x / (1.9 * gnRatio)) -- Display the model properly xyPos.x = xyTmp.x - xySiz.x - xyDelta.x xySiz.y = xyTmp.y - xyPos.y - xyDelta.y -------------------------------------- @@ -866,7 +862,7 @@ if(CLIENT) then asmlib.InitLocalify(varLanguage:GetString()) pnListView.OnRowSelected = function(pnSelf, nIndex, pnLine) gtArgsLogs[1] = "OPEN_FRAME.ListView" local uiMod = tostring(pnLine:GetColumnText(5) or asmlib.GetOpVar("MISS_NOMD")) -- Actually the model in the table local uiAct = (tonumber(pnLine:GetColumnText(2)) or 0); pnModelPanel:SetModel(uiMod) -- Active points amount - local uiBox = asmlib.CacheBoxLayout(pnModelPanel:GetEntity(),0,nRatio,nRatio-1); if(not asmlib.IsHere(uiBox)) then + local uiBox = asmlib.CacheBoxLayout(pnModelPanel:GetEntity(),0,gnRatio,gnRatio-1); if(not asmlib.IsHere(uiBox)) then asmlib.LogInstance("ListView.OnRowSelected Box invalid for <"..uiMod..">",gtArgsLogs); return nil end pnModelPanel:SetLookAt(uiBox.Eye); pnModelPanel:SetCamPos(uiBox.Cam) local pointid, pnextid = asmlib.GetAsmConvar("pointid","INT"), asmlib.GetAsmConvar("pnextid","INT") diff --git a/lua/trackassembly/trackasmlib.lua b/lua/trackassembly/trackasmlib.lua index 4e7ab9c..8433d4a 100644 --- a/lua/trackassembly/trackasmlib.lua +++ b/lua/trackassembly/trackasmlib.lua @@ -112,7 +112,7 @@ local timerStart = timer and timer.Start local timerSimple = timer and timer.Simple local timerExists = timer and timer.Exists local timerCreate = timer and timer.Create -local timerDestroy = timer and timer.Destroy +local timerRemove = timer and timer.Remove local tableEmpty = table and table.Empty local tableMaxn = table and table.maxn local tableGetKeys = table and table.GetKeys @@ -2165,7 +2165,7 @@ function CreateTable(sTable,defTab,bDelete,bReload) timerCreate(tmID, tmLif, 1, function() LogInstance("["..tmID.."]("..tmLif..") > Dead",tabDef.Nick) if(tmDie) then oSpot[kKey] = nil; LogInstance("Killed <"..kKey..">",tabDef.Nick) end - timerStop(tmID); timerDestroy(tmID) + timerStop(tmID); timerRemove(tmID) if(tmCol) then collectgarbage(); LogInstance("Garbage collected",tabDef.Nick) end end); timerStart(tmID); return oSpot[kKey] else LogInstance("Mode mismatch <"..smTM..">",tabDef.Nick); return oSpot[kKey] end @@ -3018,7 +3018,7 @@ function SynchronizeDSV(sTable, tData, bRepl, sPref, sDelim) if(bRepl) then -- Replace the data when enabled overwrites the file data if(tData[vK]) then -- Update the file with the new data fData[vK] = tRec; fData[vK].Size = #tRec end - else --[[ Do not modify fData ]] end + end end local tSort = Sort(tableGetKeys(fData)); if(not tSort) then LogInstance("("..fPref.."@"..sTable..") Sorting failed"); return false end diff --git a/lua/weapons/gmod_tool/stools/trackassembly.lua b/lua/weapons/gmod_tool/stools/trackassembly.lua index 2cb2a87..4d60575 100644 --- a/lua/weapons/gmod_tool/stools/trackassembly.lua +++ b/lua/weapons/gmod_tool/stools/trackassembly.lua @@ -451,14 +451,13 @@ end function TOOL:GetWorkingMode() -- Put cases in new mode resets here local workmode = mathClamp(self:GetClientNumber("workmode") or 0, 1, conWorkMode:GetSize()) -- Perform various actions to stabilize data across working modes - if (workmode == 1) then self:IntersectClear(true) -- Reset ray list in snap mode - elseif(workmode == 2) then --[[ Nothing to reset in intersect mode ]] end + if(workmode == 1) then self:IntersectClear(true) end -- Reset ray list in snap mode return workmode, tostring(conWorkMode:Select(workmode) or gsNoAV):sub(1,6) end -- Reset settings server-side where available and return the value function TOOL:GetStatus(stTr,vMsg,hdEnt) local iMaxlog = asmlib.GetOpVar("LOG_MAXLOGS") - if(not (iMaxlog > 0)) then return "Status N/A" end + if(iMaxlog <= 0) then return "Status N/A" end local ply, sDelim = self:GetOwner(), "\n" local iCurLog = asmlib.GetOpVar("LOG_CURLOGS") local bFleLog = asmlib.IsFlag("en_logging_file")