Branch Coverage

include/eshu_file.h
Criterion Covered Total %
branch 130 348 37.3


line true false branch
74 39 0 if (r->file) free(r->file);
75 36 3 if (r->lang) free(r->lang);
76 3 36 if (r->reason) free(r->reason);
77 0 39 if (r->error) free(r->error);
78 1 38 if (r->diff) free(r->diff);
103 0 0 if (r->changes_count >= r->changes_cap) {
114 0 0 for (i = 0; i < r->changes_count; i++)
126 156 0 if (a >= 'A' && a <= 'Z') a += 32;
0 156 if (a >= 'A' && a <= 'Z') a += 32;
127 156 0 if (b >= 'A' && b <= 'Z') b += 32;
0 156 if (b >= 'A' && b <= 'Z') b += 32;
137 115 0 while (p > path) {
139 38 77 if (*p == '.') { dot = p + 1; break; }
140 77 0 if (*p == '/' || *p == '\\') break;
77 0 if (*p == '/' || *p == '\\') break;
142 0 38 if (!dot) return NULL;
146 3 35 if (ext_len == 1 && (eshu_ci(dot[0], 'c') || eshu_ci(dot[0], 'h')))
0 3 if (ext_len == 1 && (eshu_ci(dot[0], 'c') || eshu_ci(dot[0], 'h')))
0 0 if (ext_len == 1 && (eshu_ci(dot[0], 'c') || eshu_ci(dot[0], 'h')))
149 31 4 if (ext_len == 2 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's'))
0 31 if (ext_len == 2 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's'))
152 31 4 if (ext_len == 2 && eshu_ci(dot[0], 'p')
31 0 if (ext_len == 2 && eshu_ci(dot[0], 'p')
153 26 5 && (eshu_ci(dot[1], 'l') || eshu_ci(dot[1], 'm')))
26 0 && (eshu_ci(dot[1], 'l') || eshu_ci(dot[1], 'm')))
156 0 4 if (ext_len == 1 && eshu_ci(dot[0], 't'))
0 0 if (ext_len == 1 && eshu_ci(dot[0], 't'))
159 4 0 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l'))
1 3 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l'))
1 0 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l'))
1 0 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'm') && eshu_ci(dot[2], 'l'))
162 3 0 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l'))
0 3 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'l'))
165 0 3 if (ext_len == 4 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 's')
166 0 0 && eshu_ci(dot[2], 'l') && eshu_ci(dot[3], 't'))
0 0 && eshu_ci(dot[2], 'l') && eshu_ci(dot[3], 't'))
169 3 0 if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g'))
0 3 if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'v') && eshu_ci(dot[2], 'g'))
172 0 3 if (ext_len == 5 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'h')
0 0 if (ext_len == 5 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'h')
0 0 if (ext_len == 5 && eshu_ci(dot[0], 'x') && eshu_ci(dot[1], 'h')
173 0 0 && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l'))
0 0 && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l'))
0 0 && eshu_ci(dot[2], 't') && eshu_ci(dot[3], 'm') && eshu_ci(dot[4], 'l'))
176 0 3 if (ext_len == 4 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't')
177 0 0 && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l'))
0 0 && eshu_ci(dot[2], 'm') && eshu_ci(dot[3], 'l'))
180 3 0 if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm'))
0 3 if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'h') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 'm'))
183 0 3 if (ext_len == 4 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 'm')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 'm')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 'm')
184 0 0 && eshu_ci(dot[2], 'p') && eshu_ci(dot[3], 'l'))
0 0 && eshu_ci(dot[2], 'p') && eshu_ci(dot[3], 'l'))
187 0 3 if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 't'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 't'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 't'))
190 0 3 if (ext_len == 2 && eshu_ci(dot[0], 'e') && eshu_ci(dot[1], 'p'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 'e') && eshu_ci(dot[1], 'p'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 'e') && eshu_ci(dot[1], 'p'))
193 3 0 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's'))
1 2 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's'))
1 0 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's'))
1 0 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 's'))
196 0 2 if (ext_len == 4 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'c')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'c')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 's') && eshu_ci(dot[1], 'c')
197 0 0 && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's'))
0 0 && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's'))
200 0 2 if (ext_len == 4 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'e')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'e')
0 0 if (ext_len == 4 && eshu_ci(dot[0], 'l') && eshu_ci(dot[1], 'e')
201 0 0 && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's'))
0 0 && eshu_ci(dot[2], 's') && eshu_ci(dot[3], 's'))
205 0 2 if (ext_len == 2 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's'))
208 2 0 if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
0 2 if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'j') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
211 2 0 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
0 2 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
214 2 0 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
0 2 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'c') && eshu_ci(dot[1], 'j') && eshu_ci(dot[2], 's'))
217 0 2 if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's'))
0 0 if (ext_len == 2 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's'))
220 2 0 if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
2 0 if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
0 2 if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 't') && eshu_ci(dot[1], 's') && eshu_ci(dot[2], 'x'))
223 2 0 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's'))
0 2 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'm') && eshu_ci(dot[1], 't') && eshu_ci(dot[2], 's'))
227 2 0 if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd'))
0 2 if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd'))
0 0 if (ext_len == 3 && eshu_ci(dot[0], 'p') && eshu_ci(dot[1], 'o') && eshu_ci(dot[2], 'd'))
240 0 36 if (!lang) return -1;
241 3 33 if (strcmp(lang, "c") == 0) return ESHU_LANG_C;
242 31 2 if (strcmp(lang, "perl") == 0) return ESHU_LANG_PERL;
243 0 2 if (strcmp(lang, "pl") == 0) return ESHU_LANG_PERL;
244 0 2 if (strcmp(lang, "xs") == 0) return ESHU_LANG_XS;
245 1 1 if (strcmp(lang, "xml") == 0) return ESHU_LANG_XML;
246 0 1 if (strcmp(lang, "xsl") == 0) return ESHU_LANG_XML;
247 0 1 if (strcmp(lang, "xslt") == 0) return ESHU_LANG_XML;
248 0 1 if (strcmp(lang, "svg") == 0) return ESHU_LANG_XML;
249 0 1 if (strcmp(lang, "xhtml") == 0) return ESHU_LANG_XML;
250 0 1 if (strcmp(lang, "html") == 0) return ESHU_LANG_HTML;
251 0 1 if (strcmp(lang, "htm") == 0) return ESHU_LANG_HTML;
252 0 1 if (strcmp(lang, "tmpl") == 0) return ESHU_LANG_HTML;
253 0 1 if (strcmp(lang, "tt") == 0) return ESHU_LANG_HTML;
254 0 1 if (strcmp(lang, "ep") == 0) return ESHU_LANG_HTML;
255 1 0 if (strcmp(lang, "css") == 0) return ESHU_LANG_CSS;
256 0 0 if (strcmp(lang, "scss") == 0) return ESHU_LANG_CSS;
257 0 0 if (strcmp(lang, "less") == 0) return ESHU_LANG_CSS;
258 0 0 if (strcmp(lang, "js") == 0) return ESHU_LANG_JS;
259 0 0 if (strcmp(lang, "javascript") == 0) return ESHU_LANG_JS;
260 0 0 if (strcmp(lang, "jsx") == 0) return ESHU_LANG_JS;
261 0 0 if (strcmp(lang, "mjs") == 0) return ESHU_LANG_JS;
262 0 0 if (strcmp(lang, "cjs") == 0) return ESHU_LANG_JS;
263 0 0 if (strcmp(lang, "ts") == 0) return ESHU_LANG_JS;
264 0 0 if (strcmp(lang, "typescript") == 0) return ESHU_LANG_JS;
265 0 0 if (strcmp(lang, "tsx") == 0) return ESHU_LANG_JS;
266 0 0 if (strcmp(lang, "mts") == 0) return ESHU_LANG_JS;
267 0 0 if (strcmp(lang, "pod") == 0) return ESHU_LANG_POD;
320 39 0 if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) {
0 39 if (stat(path, &st) != 0 || !S_ISREG(st.st_mode)) {
327 0 39 if (st.st_size > ESHU_MAX_FILE_SIZE) {
335 0 39 if (!fp) {
342 0 39 if (fread(src, 1, src_len, fp) != src_len) {
353 39 0 if (src_len > 0) {
355 1 38 if (memchr(src, '\0', check) != NULL) {
364 38 0 lang_str = force_lang ? force_lang : eshu_detect_lang_ext(path);
365 2 36 if (!lang_str) {
372 0 36 if (lang_id < 0) {
387 2 34 if (out_len == src_len && memcmp(fixed, src, src_len) == 0) {
2 0 if (out_len == src_len && memcmp(fixed, src, src_len) == 0) {
391 12 22 ? ESHU_STATUS_CHANGED : ESHU_STATUS_NEEDS_FIXING;
393 12 22 if (opts & ESHU_OPT_FIX) {
395 0 12 if (!fp) {
405 1 33 if (opts & ESHU_OPT_DIFF) {
432 0 46 if (l->count >= l->cap) {
449 46 16 for (i = 0; i < l->count; i++) free(l->items[i]);
468 0 22 if (!d) return;
470 99 22 while ((ent = readdir(d)) != NULL) {
471 44 55 if (ent->d_name[0] == '.') continue;
475 0 55 if (lstat(pathbuf, &st) != 0) continue;
477 4 51 if (S_ISLNK(st.st_mode)) {
480 4 0 if (stat(pathbuf, &tgt) == 0 && S_ISREG(tgt.st_mode)) {
2 2 if (stat(pathbuf, &tgt) == 0 && S_ISREG(tgt.st_mode)) {
483 44 7 } else if (S_ISREG(st.st_mode)) {
485 6 1 } else if (recursive && S_ISDIR(st.st_mode)) {
6 0 } else if (recursive && S_ISDIR(st.st_mode)) {
495 0 0 if (lstat(path, &lst) != 0) return 0;
496 0 0 if (!S_ISLNK(lst.st_mode)) return 0;
497 0 0 if (stat(path, &st) != 0) return 0;