From 00a0c881a21467c0cf6acac4aa00cb0b54509ab0 Mon Sep 17 00:00:00 2001 From: David Leal Date: Wed, 6 May 2020 13:58:07 -0500 Subject: [PATCH] Add Travis CI and LuaCheck (#2) --- .luacheckrc | 19 +++++++++++++++++++ .travis.yml | 11 +++++++++++ README.md | 1 + init.lua | 4 ++-- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .luacheckrc create mode 100644 .travis.yml diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..6a96445 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,19 @@ +unused_args = false +allow_defined_top = true +max_line_length = 999 + +globals ={ + "minetest", +} + +read_globals = { + string = {fields = {"split", "trim"}}, + table = {fields = {"copy", "getn"}}, +} + +files["init.lua"].ignore = { "modname", "tab" } +files["mysql/mysql.lua"].ignore = { "" } +files["mysql/mysql_h.lua"].ignore = { "" } +files["mysql/mysql_print.lua"].ignore = { "" } +files["mysql/mysql_test.lua"].ignore = { "" } + -- ^ Ignore everything diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4c59300 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: generic +addons: + apt: + packages: + - luarocks +before_install: + - luarocks install --local luacheck +script: +- $HOME/.luarocks/bin/luacheck . +notifications: + email: false diff --git a/README.md b/README.md index 56cd50b..d22a8f2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # mysql_base +[![Build Status](https://travis-ci.org/MinetestForFun/mysql_base.svg)](https://travis-ci.org/MinetestForFun/mysql_base) Base Minetest mod to connect to a MySQL database. Used by other mods to read/write data. diff --git a/init.lua b/init.lua index 9950898..36f62d9 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ local modname = minetest.get_current_modname() -local modpath = minetest.get_modpath(modname) +local modpath = minetest.get_modpath(modname) local thismod = { enabled = false, @@ -69,7 +69,7 @@ local function string_splitdots(s) local word_bound = i - 1 table.insert(temp, string.sub(s, index, word_bound)) index = next_index - else + else if index > 0 and index <= last_index then table.insert(temp, string.sub(s, index, last_index)) elseif index == 0 then