| 111 | } |
| 112 | |
| 113 | bool 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 | } |
nothing calls this directly
no test coverage detected