TerraME / terrame

TerraME is a programming environment for spatial dynamical modelling
www.terrame.org
GNU Lesser General Public License v3.0
36 stars 13 forks source link

new command option: -check #1412

Closed pedro-andrade-inpe closed 7 years ago

pedro-andrade-inpe commented 8 years ago

Distribute luacheck as a TerraME package and Implement command option -check to use luacheck to verify the scripts to be executed.

pedro-andrade-inpe commented 7 years ago

Current configuration file for the CI server:

std = "min"
cache = true
global = false
avancinirodrigo commented 7 years ago

The integration can be simple if the luacheck is handled as a module. Currently, TerraME knows modules that are in its executable directory. Thus, CMake can put the molule as a library (dll, so, etc). It was created a prototype of the command in TerraME like:

#> terrame -check cellspace.lua

out:

Line: 61 column: 16 code:211 message: unused function 'printTable'
Line: 86 column: 8 code:211 message: unused variable 'dSet' 

The code for this:

            elseif arg == "-check" then
                local file = arguments[argCount + 1]
                local luacheck = require("luacheck")
                local files = {file}
                local options = {std = "min", cache = true, global = false}             
                local issues = luacheck.check_files(files, options)[1]
                for _, issue in ipairs(issues) do
                    print("Line: "..issue.line.." column: "..issue.column.." code:"..issue.code.." message: "..luacheck.get_message(issue))
                end     
                os.exit(0)

@pedro-andrade-inpe, Now, I need a full specification to continue the integration.

avancinirodrigo commented 7 years ago

Important link: http://luacheck.readthedocs.io/en/stable/module.html