MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / CheckWorkspace

Method CheckWorkspace

CodeFormat/src/LuaCheck.cpp:113–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113bool LuaCheck::CheckWorkspace(const FormatContext &context) {
114 auto workspace = context.GetWorkspace();
115 bool diagnosis = false;
116 FileFinder finder(workspace);
117 finder.AddFindExtension(".lua");
118 finder.AddFindExtension(".lua.txt");
119 finder.AddIgnoreDirectory(".git");
120 finder.AddIgnoreDirectory(".github");
121 finder.AddIgnoreDirectory(".svn");
122 finder.AddIgnoreDirectory(".idea");
123 finder.AddIgnoreDirectory(".vs");
124 finder.AddIgnoreDirectory(".vscode");
125 for (const auto &pattern: context.GetIgnorePattern()) {
126 finder.AddIgnorePatterns(pattern);
127 }
128
129 auto files = finder.FindFiles();
130 for (auto &filePath: files) {
131 auto opText = ReadFile(filePath);
132 std::string relativePath = filePath;
133 if (!workspace.empty()) {
134 relativePath = string_util::GetFileRelativePath(workspace, filePath);
135 }
136 if (opText.has_value()) {
137 auto style = context.GetStyle(relativePath);
138 if (CheckSingleFile(context, relativePath, std::move(opText.value()), style)) {
139 std::cerr << util::format("Check {} ok.", relativePath) << std::endl;
140 } else {
141 diagnosis = true;
142 }
143 } else {
144 std::cerr << util::format("Can not read file {}", relativePath) << std::endl;
145 }
146 }
147 return !diagnosis;
148}

Callers

nothing calls this directly

Calls 10

ReadFileFunction · 0.85
GetWorkspaceMethod · 0.80
AddFindExtensionMethod · 0.80
AddIgnoreDirectoryMethod · 0.80
AddIgnorePatternsMethod · 0.80
FindFilesMethod · 0.80
GetStyleMethod · 0.80
formatFunction · 0.50
emptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected