Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config formatter not working? #189

Open
Dols592 opened this issue Jan 5, 2019 · 1 comment
Open

config formatter not working? #189

Dols592 opened this issue Jan 5, 2019 · 1 comment

Comments

@Dols592
Copy link

Dols592 commented Jan 5, 2019

I'm trying to add a formatter to the configuration file. I run into a strange problem. I cannot use standard lua functions. for pairs, ipairs, table functions are not recognized.

I'm using the current latest version of the windows precompiled binairy of luacheck. Rest of config is empty.

This works:

  formatter = function(report, filenames, combined_opts)
    return "Test 1\r\nTest 2\r\n"
  end

This fails with error

Critical error: Couldn't run custom formatter 'function: 00000177b50307f0': [string "chunk"]:3: attempt to call a nil value (global 'pairs')

  formatter = function(report, filenames, combined_opts)
    local days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
    for j, i in pairs(days) do
    end
    return ""
  end
@Dols592
Copy link
Author

Dols592 commented Jan 5, 2019

I fixed it by using the not a function but a custom formatter name.
Added next in the config file.
formatter = "customFormatter"

Next in the customFormatter.lua

return function(report, filenames, combined_opts)
    local days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
    for j, i in pairs(days) do
    end
    return ""
end

Of course the content of the function is useless as a formatter. But is executed without errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant