<commit_before>package synchk

import (
	"gosubli.me/mg"
	"gosubli.me/mg/sa"
)

type SynChk struct {
	Files []FileRef
}

type FileRef struct {
	Fn  string
	Src string
}

type Res struct {
	Errors []*sa.Error
}

func (s *SynChk) Call() (interface{}, string) {
	res := Res{}
	for _, f := range s.Files {
		if f, _ := sa.Parse(f.Fn, []byte(f.Src)); f != nil {
			res.Errors = append(res.Errors, f.Errors...)
		}
	}
	return res, ""
}

func init() {
	mg.Register("synchk", func(_ *mg.Broker) mg.Caller {
		return &SynChk{}
	})
}<commit_msg>synchk: Be explicit in what fields we send to clients. Make sure put the request's filename in the errors to avoid reporting errors in the wrong file. The latter is a sife-effect of the cache being based on content rather than filename, so if you rename a file, you'd see errors for the wrong file.<commit_after>package synchk

import (
	"gosubli.me/mg"
	"gosubli.me/mg/sa"
)

type SynChk struct {
	Files []FileRef
}

type FileRef struct {
	Fn  string
	Src string
}

type Res struct {
	Errors []*sa.Error
}

func (s *SynChk) Call() (interface{}, string) {
	res := Res{}
	for _, f := range s.Files {
		if sf, _ := sa.Parse(f.Fn, []byte(f.Src)); sf != nil {
			for _, e := range sf.Errors {
				res.Errors = append(res.Errors, &sa.Error{
					Fn:      f.Fn,
					Line:    e.Line,
					Column:  e.Column,
					Offset:  e.Offset,
					Message: e.Message,
				})
			}
		}
	}
	return res, ""
}

func init() {
	mg.Register("synchk", func(_ *mg.Broker) mg.Caller {
		return &SynChk{}
	})
}
{'fraction_non_alphanumeric': 0.1503957783641161, 'fraction_numerical': 0.0, 'mean_word_length': 3.023872679045093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '809279', 'n_tokens_mistral': 619, 'n_tokens_neox': 577, 'n_words': 174}