diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 2756ad1ca..9c8b398d8 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -21,4 +21,4 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master with: - ignore: sidebar hooks + ignore: sidebar diff --git a/hooks/commit-msg b/hooks/commit-msg index cc4bf7316..6efe363eb 100755 --- a/hooks/commit-msg +++ b/hooks/commit-msg @@ -47,6 +47,7 @@ function log() { function run_prepend_commit_msg() { GREP_REGEX="" + # shellcheck disable=SC2068 for t in ${VALID_START_REGEX[@]}; do GREP_REGEX="$GREP_REGEX|^$t: " done @@ -58,6 +59,7 @@ function run_prepend_commit_msg() { log "$COMMIT_MSG_EXIT_CODE" "Commit message prepended" else COMMIT_MSG_EXIT_CODE="1" + # shellcheck disable=SC2068 for t in ${VALID_START_REGEX[@]}; do echo -e "\e[32m$t:\e[39m \e[33m$1\e[39m" done @@ -109,7 +111,7 @@ function run_check_if_merge_commit { fi } -data="$(sed '/^ *#/d' "$1")" +data="$(sed '/^ *#/d' "$MSG")" run_check_if_merge_commit "$data" run_prepend_commit_msg "$data" diff --git a/hooks/pre-commit b/hooks/pre-commit index bbd890c88..f3e28e359 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -30,7 +30,7 @@ function log() { len="$((${#2} - 1))" columns=$(tput cols) echo -en "$2 " - printf '.%.0s' $(seq $(( $columns - $len - 15))) + printf '.%.0s' $(seq $(( columns - len - 15))) if [[ "$1" == "$WARNING" ]]; then _warning="${3:-WARNING}" @@ -65,6 +65,7 @@ function run_linter_shell() { SHELL_LINTING_OUT="" SHELL_LINTING_EXIT_CODE="" + # shellcheck disable=SC2044 for file in $(find . -type f -name "*.sh" ! -name "rofi-spotlight.sh"); do out="$(shellcheck "$file")" code="$?" @@ -105,6 +106,7 @@ function run_license_linter_lua() { --SOFTWARE. ]]" _LICENSE_LUA_OUT="" + # shellcheck disable=SC2044 for file in $(find . -type f -name "*.lua" ! -name "release.lua" -not -path "*lib-lua*"); do out="$(head -n24 "$file")" if [[ ! "$out" == "$_LICENSE" ]]; then @@ -147,6 +149,7 @@ function run_license_linter_bash() { # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE." _LICENSE_BASH_OUT="" + # shellcheck disable=SC2044 for file in $(find . -type f -name "*.sh"); do out="$(head -n24 "$file")" if [[ ! "$out" == "$_LICENSE" ]]; then @@ -163,7 +166,7 @@ function run_license_linter_bash() { } function run_test_suite() { - if [[ "$(cat /etc/os-release | grep '^NAME' | cut -d'=' -f2 | tr -d '"')" == "TOS Linux" ]]; then + if [[ "$(grep '^NAME' /etc/os-release | cut -d'=' -f2 | tr -d '"')" == "TOS Linux" ]]; then UNIT_TEST_OUT="$(bash test-runner.sh 2>/dev/null)" UNIT_EXIT_CODE="$?" else diff --git a/hooks/pre-push b/hooks/pre-push index e474b116d..757cd8946 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -29,7 +29,7 @@ function log() { len="$((${#2} - 1))" columns=$(tput cols) echo -en "$2 " - printf '.%.0s' $(seq $(($columns - $len - 15))) + printf '.%.0s' $(seq $((columns - len - 15))) if [[ ! "$1" -eq "0" ]]; then echo -e " \e[30m\e[41m FAILED \e[49m\e[39m" diff --git a/plugins/calendar-bare-widget/init.lua b/plugins/calendar-bare-widget/init.lua index efa2a67e7..881abd1f0 100644 --- a/plugins/calendar-bare-widget/init.lua +++ b/plugins/calendar-bare-widget/init.lua @@ -40,7 +40,7 @@ local cal = } -- generate a text widget that acts like the header -header = +local header = wibox.widget { text = "Calendar", font = "SFNS Display Regular 14", diff --git a/plugins/desktop-widgets/widgets.lua b/plugins/desktop-widgets/widgets.lua index 40e096073..894a60dc0 100644 --- a/plugins/desktop-widgets/widgets.lua +++ b/plugins/desktop-widgets/widgets.lua @@ -34,9 +34,8 @@ local rounded = require("lib-tde.widget.rounded") -- title is the text below the progress bar -- timeout is an optional value that specifies how often to update the widget default to one second -- bar_size is an optional value that specifies how thick the radial bar should be -local chart = function(x, y, width, height, title, fillFunc, timeout, bar_size) +local chart = function(x, y, width, height, title, fillFunc, timeout, _) timeout = timeout or 1 - bar_size = bar_size or 8 local margin_ratio = 0.10 -- in percentage local bar_ratio = 0.75 -- in percentage diff --git a/plugins/docker-widget/init.lua b/plugins/docker-widget/init.lua index b634a3488..380330887 100644 --- a/plugins/docker-widget/init.lua +++ b/plugins/docker-widget/init.lua @@ -145,7 +145,7 @@ local status_to_icon_name = { } local function worker(args) - local args = args or {} + args = args or {} local icon = args.icon or ICONS_DIR .. "docker.svg" local number_of_containers = args.number_of_containers or -1 @@ -225,14 +225,14 @@ local function worker(args) awful.spawn.easy_async( "docker " .. command .. " " .. container["name"], - function(stdout, stderr) - if stderr ~= "" then - show_warning(stderr) + function(_, stderr_2) + if stderr_2 ~= "" then + show_warning(stderr_2) end spawn.easy_async( string.format(LIST_CONTAINERS_CMD, number_of_containers), - function(stdout, stderr) - rebuild_widget(stdout, stderr) + function(stdout_3, stderr_3) + rebuild_widget(stdout_3, stderr_3) end ) end @@ -293,14 +293,14 @@ local function worker(args) awful.spawn.easy_async( "docker " .. command .. " " .. container["name"], - function(stdout, stderr) - if stderr ~= "" then - show_warning(stderr) + function(_, stderr2) + if stderr2 ~= "" then + show_warning(stderr2) end spawn.easy_async( string.format(LIST_CONTAINERS_CMD, number_of_containers), - function(stdout, stderr) - rebuild_widget(stdout, stderr) + function(stdout3, stderr3) + rebuild_widget(stdout3, stderr3) end ) end diff --git a/plugins/error-widget/init.lua b/plugins/error-widget/init.lua index 6578a17a7..9072874f0 100644 --- a/plugins/error-widget/init.lua +++ b/plugins/error-widget/init.lua @@ -26,7 +26,7 @@ --local wibox = require("wibox") -- generate a text widget that acts like the header -header = +local header = wibox.widget { text = "Error", font = "SFNS Display Regular 14", diff --git a/plugins/github-contributions-widget/init.lua b/plugins/github-contributions-widget/init.lua index 15cf2712a..5e0fe5425 100644 --- a/plugins/github-contributions-widget/init.lua +++ b/plugins/github-contributions-widget/init.lua @@ -39,9 +39,6 @@ local dpi = require("beautiful").xresources.apply_dpi local GET_CONTRIBUTIONS_CMD = [[bash -c "curl -s https://github-contributions.now.sh/api/v1/%s | jq -r '[.contributions[] | select ( .date | strptime(\"%%Y-%%m-%%d\") | mktime < now)][:%s]| .[].color'"]] --- in case github-contributions.now.sh stops working contributions can be scrapped from the github.com with the command below. Note that the order is reversed. -local GET_CONTRIBUTIONS_CMD_FALLBACK = - [[bash -c "curl -s https://github.com/users/%s/contributions | grep -o '\" fill=\"\#[0-9a-fA-F]\{6\}\" da' | grep -o '\#[0-9a-fA-F]\{6\}'"]] local github_contributions_widget = wibox.widget { @@ -53,7 +50,7 @@ local github_contributions_widget = } local function worker(args) - local args = args or {} + args = args or {} local username = args.username or "F0xedb" local days = args.days or 60 @@ -77,10 +74,10 @@ local function worker(args) local r, g, b = hex2rgb(color) return wibox.widget { - fit = function(self, context, width, height) + fit = function(_, _, _, _) return dpi(7), dpi(7) end, - draw = function(self, context, cr, width, height) + draw = function(_, _, cr, _, _) cr:set_source_rgb(r / 255, g / 255, b / 255) cr:rectangle(0, 0, with_border and dpi(5) or dpi(7), with_border and dpi(5) or dpi(7)) cr:fill() @@ -92,11 +89,11 @@ local function worker(args) local col = {layout = wibox.layout.fixed.vertical} local row = {layout = wibox.layout.fixed.horizontal} local a = 5 - os.date("%w") - for i = 0, a do + for _ = 0, a do table.insert(col, get_square("#ebedf0")) end - local update_widget = function(widget, stdout, _, _, _) + local update_widget = function(_, stdout, _, _, _) for colors in stdout:gmatch("[^\r\n]+") do if a % 7 == 0 then table.insert(row, col) @@ -116,7 +113,7 @@ local function worker(args) awful.spawn.easy_async( string.format(GET_CONTRIBUTIONS_CMD, username, days), - function(stdout, stderr) + function(stdout, _) update_widget(github_contributions_widget, stdout) end ) diff --git a/plugins/hello-world-widget/init.lua b/plugins/hello-world-widget/init.lua index 83f700ecc..6da3e00a3 100644 --- a/plugins/hello-world-widget/init.lua +++ b/plugins/hello-world-widget/init.lua @@ -33,7 +33,7 @@ local beautiful = require("beautiful") local PATH_TO_ICONS = os.getenv("HOME") .. "/.config/tde/hello-world-widget/icons/" -- generate the icon widget -hello_icon_widget = +local hello_icon_widget = wibox.widget { { id = "icon", @@ -47,7 +47,7 @@ hello_icon_widget = } -- generate a text widget that acts like the header -hello_header = +local hello_header = wibox.widget { text = "Hello, World!", font = "SFNS Display Regular 14", @@ -57,7 +57,7 @@ hello_header = } -- generate a text widget that acts like a subtitle -hello_subtitle = +local hello_subtitle = wibox.widget { text = "Good to see you", font = "SFNS Display Regular 16", diff --git a/plugins/jira-widget/init.lua b/plugins/jira-widget/init.lua index e07ad0235..677aa3e64 100644 --- a/plugins/jira-widget/init.lua +++ b/plugins/jira-widget/init.lua @@ -41,7 +41,6 @@ local naughty = require("naughty") local gears = require("gears") local beautiful = require("beautiful") local gfs = require("gears.filesystem") -local color = require("gears.color") local clickable_container = require("widget.material.clickable-container") local dpi = require("beautiful").xresources.apply_dpi @@ -76,23 +75,11 @@ local image = local button = wibox.container.margin(image, 0, dpi(5), 0, 0) -local urgent_widget = { - id = "d", - draw = function(self, context, cr, width, height) - cr:set_source(color(beautiful.fg_urgent)) - cr:arc(height / 4, height / 4, height / 4, 0, math.pi * 2) - cr:fill() - end, - visible = false, - layout = wibox.widget.base.make_widget -} - local jira_widget = wibox.widget { { { button, - urgent, id = "b", layout = wibox.layout.stack }, @@ -108,17 +95,15 @@ local jira_widget = set_text = function(self, new_value) self.txt.text = new_value end, - set_icon = function(self, path) + set_icon = function(_, path) image:set_icon(path) end, is_everything_ok = function(self, is_ok) if is_ok then - urgent_widget.visible = false image:set_opacity(1) image:emit_signal("widget:redraw_needed") else self.txt:set_text("") - urgent_widget.visible = true image:set_opacity(0.2) image:emit_signal("widget:redraw_needed") end @@ -162,7 +147,7 @@ local tooltip = preferred_positions = {"bottom"} } -local function createRow(issue, host, path_to_avatar) +local function createRow(issue, host_in, path_to_avatar) local row = wibox.widget { { @@ -224,7 +209,7 @@ local function createRow(issue, host, path_to_avatar) {}, 1, function() - spawn.with_shell("xdg-open " .. host .. "/browse/" .. issue.key) + spawn.with_shell("xdg-open " .. host_in .. "/browse/" .. issue.key) popup.visible = false grabber:stop() end @@ -234,7 +219,7 @@ local function createRow(issue, host, path_to_avatar) return row end -local function createRowTable(issues, host) +local function createRowTable(issues, host_in) local rows = { {widget = wibox.widget.textbox}, layout = wibox.layout.fixed.vertical @@ -255,14 +240,14 @@ local function createRowTable(issues, host) ) end end - table.insert(rows, createRow(issue, host, path_to_avatar)) + table.insert(rows, createRow(issue, host_in, path_to_avatar)) end return rows end -local function createTable(result, host, maxelements) +local function createTable(result_in, host_in, maxelements) if maxelements == nil then - maxelements = #result.issues + maxelements = #result_in.issues end -- the partial variable hold the result set of one vertical table set @@ -270,11 +255,11 @@ local function createTable(result, host, maxelements) local previousTableIndex = 1 -- arr holds the information about one vertical table set local arr = {} - for index, issue in ipairs(result.issues) do + for index, issue in ipairs(result_in.issues) do -- get the index in the table local tableIndex = math.ceil(index / maxelements) if not (previousTableIndex == tableIndex) then - table.insert(arr, createRowTable(partialIssues, host)) + table.insert(arr, createRowTable(partialIssues, host_in)) -- reset variable for next vertical set partialIssues = {} previousTableIndex = tableIndex @@ -282,7 +267,7 @@ local function createTable(result, host, maxelements) table.insert(partialIssues, issue) print("Inserting issue: " .. issue.key .. " into " .. tableIndex) end - table.insert(arr, createRowTable(partialIssues, host)) + table.insert(arr, createRowTable(partialIssues, host_in)) local table_widget = wibox.widget { arr[1], @@ -301,7 +286,7 @@ local function createTable(result, host, maxelements) end local function worker(args) - local args = args or {} + args = args or {} local icon = args.icon or HOME_DIR .. "/.config/tde/jira-widget/jira-mark-gradient-blue.svg" host = args.host or show_warning("Jira host is unknown") diff --git a/plugins/jira-widget/json.lua b/plugins/jira-widget/json.lua index 9da4108e8..2a7279715 100644 --- a/plugins/jira-widget/json.lua +++ b/plugins/jira-widget/json.lua @@ -73,7 +73,7 @@ local function escape_char(c) return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) end -local function encode_nil(val) +local function encode_nil(_) return "null" end @@ -101,7 +101,7 @@ local function encode_table(val, stack) error("invalid table: sparse array") end -- Encode - for i, v in ipairs(val) do + for _, v in ipairs(val) do table.insert(res, encode(v, stack)) end stack[val] = nil diff --git a/plugins/settings-app-widget/init.lua b/plugins/settings-app-widget/init.lua index 4fa02eb3a..480563425 100644 --- a/plugins/settings-app-widget/init.lua +++ b/plugins/settings-app-widget/init.lua @@ -79,7 +79,7 @@ local function create() local function decorate_cell(widget, flag, _) local props = styles[flag] or {} - ret = widget + local ret = widget if flag == "focus" then ret = wibox.container.margin( diff --git a/plugins/snake/init.lua b/plugins/snake/init.lua index 712367405..1fc0d5be8 100644 --- a/plugins/snake/init.lua +++ b/plugins/snake/init.lua @@ -58,8 +58,8 @@ local size = dpi(20) -- 10 and 50 have a margin of error of 40 -- this function returns true when the margin is smaller that local function margin_of_error(point1, point2, margin) - local smaller = 0 - local bigger = 0 + local smaller + local bigger if point1 == point2 then return true end @@ -81,8 +81,8 @@ end -- create one "section" of the snake at a specific x and y position -- if head and fruit define the color of the box -local function createPart(x, y, head, fruit) - local bg = head or fruit or beautiful.accent.hue_800 +local function createPart(x, y, head, fruit_in) + local bg = head or fruit_in or beautiful.accent.hue_800 local box = wibox( { diff --git a/profiler/init.lua b/profiler/init.lua index d857a8d9d..9d6d3afbb 100644 --- a/profiler/init.lua +++ b/profiler/init.lua @@ -26,7 +26,7 @@ local profile_runner = require("profiler.isolation_runner") local filehandle = require("lib-tde.file") local function profile_tde() - local res, out = profile_runner.run_rc_config_in_xephyr(os.getenv("PWD") .. "/profiler/runtime.lua") + local _, out = profile_runner.run_rc_config_in_xephyr(os.getenv("PWD") .. "/profiler/runtime.lua") print(out) end @@ -36,7 +36,7 @@ local function profile_file() profile.setclock(require("socket").gettime) end profile.start() - rlprnt = print + local rlprnt = print if os.getenv("NO_FD") == "1" then print = function(_, _) diff --git a/profiler/isolation_runner.lua b/profiler/isolation_runner.lua index 6ae707f99..318f31df0 100644 --- a/profiler/isolation_runner.lua +++ b/profiler/isolation_runner.lua @@ -33,7 +33,7 @@ _G.DISPLAY_ID = 100 -- the boolean tells us if we found IT-test-result:true in the output -- this string should tell us if we encountered what we expect from the Integration Test -- The last element is the stdout from awesomewm -function run_rc_config_in_xephyr(config, starttime, endtime, funcs) +local function run_rc_config_in_xephyr(config, _, _, _) local timeout = (tonumber(os.getenv("TOTAL_TIME")) + 1) or 10 if os.getenv("MULTIPLIER") then diff --git a/profiler/profile.lua b/profiler/profile.lua index f738d1e8c..b3cb88269 100644 --- a/profiler/profile.lua +++ b/profiler/profile.lua @@ -81,10 +81,6 @@ end --- Starts collecting data. function profile.start() - if rawget(_G, "jit") then - jit.off() - jit.flush() - end debug.sethook(profile.hooker, "cr") end @@ -192,7 +188,7 @@ function profile.report(n) end -- store all internal profiler functions -for k, v in pairs(profile) do +for _, v in pairs(profile) do if type(v) == "function" then _internal[v] = true end diff --git a/profiler/runtime.lua b/profiler/runtime.lua index 87398cacd..b269f18f3 100644 --- a/profiler/runtime.lua +++ b/profiler/runtime.lua @@ -26,8 +26,8 @@ local profile = require("profiler.profile") local delayed_timer = require("lib-tde.function.delayed-timer") local filehandle = require("lib-tde.file") -originalPrint = print -print = function(str) +local originalPrint = print +print = function(_) end -- start profiling if os.getenv("REALTIME") == "1" then diff --git a/tde/.luacheckrc b/tde/.luacheckrc index 590a32671..67599ba06 100644 --- a/tde/.luacheckrc +++ b/tde/.luacheckrc @@ -53,9 +53,7 @@ exclude_files = { -- contains a lot of globals "tests/**", -- TODO: refactor plugins, then remove this - "plugins/**", - -- TODO: refactor profiler, then remove this - "profiler/**", + --"plugins/**", } -- Global objects defined by the C code @@ -78,7 +76,9 @@ read_globals = { "center", "save_state", "dont_disturb", - "clear_desktop_selection" + "clear_desktop_selection", + "wibox", + "rawlen" } -- screen may not be read-only, because newer luacheck versions complain about @@ -105,7 +105,7 @@ globals = { "taglist_occupied", "print", "echo", - "desktop_icons" + "desktop_icons", } -- Enable cache (uses .luacheckcache relative to this rc file).