Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/Config/src/LinterConfig.cpp
2746 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#include "Luau/LinterConfig.h"
3
4
#include "Luau/ParseResult.h"
5
6
namespace Luau
7
{
8
9
void LintOptions::setDefaults()
10
{
11
// By default, we enable all warnings
12
warningMask = ~0ull;
13
}
14
15
const char* LintWarning::getName(Code code)
16
{
17
LUAU_ASSERT(unsigned(code) < Code__Count);
18
19
return kWarningNames[code];
20
}
21
22
LintWarning::Code LintWarning::parseName(const char* name)
23
{
24
for (int code = Code_Unknown; code < Code__Count; ++code)
25
if (strcmp(name, getName(Code(code))) == 0)
26
return Code(code);
27
28
return Code_Unknown;
29
}
30
31
uint64_t LintWarning::parseMask(const std::vector<HotComment>& hotcomments)
32
{
33
uint64_t result = 0;
34
35
for (const HotComment& hc : hotcomments)
36
{
37
if (!hc.header)
38
continue;
39
40
if (hc.content.compare(0, 6, "nolint") != 0)
41
continue;
42
43
size_t name = hc.content.find_first_not_of(" \t", 6);
44
45
// --!nolint disables everything
46
if (name == std::string::npos)
47
return ~0ull;
48
49
// --!nolint needs to be followed by a whitespace character
50
if (name == 6)
51
continue;
52
53
// --!nolint name disables the specific lint
54
LintWarning::Code code = LintWarning::parseName(hc.content.c_str() + name);
55
56
if (code != LintWarning::Code_Unknown)
57
result |= 1ull << int(code);
58
}
59
60
return result;
61
}
62
63
} // namespace Luau
64
65