<commit_before>package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"path/filepath"
)

import (
	"github.com/longbai/checkstyle"
)

var gConfig []byte

func main() {
	config := flag.String("config", "", "config json file")

	flag.Parse()

	files := flag.Args()
	for _, v := range files {
		if isDir(v) {
			checkDir(v)
		} else {
			checkFile(v)
		}
	}
}

func isDir(filename string) bool {
	fi, err := os.Stat(filename)
	return err == nil && fi.IsDir()
}

func checkFile(fileName string) {
	file, err := ioutil.ReadAll(fileName)
	if err != nil {
		log.Printf("Read File Fail %v %v", fileName, err)
	}

	checker, err := checkstyle.New(gConfig)
	if err != nil {
		panic("New Checker Fail")
	}

	ps, err := checker.Check(fileName, file)
	if err != nil {
		log.Printf("Parse File Fail %v %v", fileName, err)
	}

	for _, v := range ps {
		fmt.Printf("%s:%v: %s\n", filename, p.Position, p.Description)
	}
}

func checkDir(dir string) {
	filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
		if err == nil && !info.IsDir() && strings.HasSuffix(path, ".go") {<commit_msg>fixed compile<commit_after>package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"strings"
)

import (
	"github.com/longbai/checkstyle"
)

var gConfig []byte
var config = flag.String("config", "", "config json file")

func main() {
	flag.Parse()

	files := flag.Args()
	for _, v := range files {
		if isDir(v) {
			checkDir(v)
		} else {
			checkFile(v)
		}
	}
}

func isDir(filename string) bool {
	fi, err := os.Stat(filename)
	return err == nil && fi.IsDir()
}

func checkFile(fileName string) {
	file, err := ioutil.ReadFile(fileName)
	if err != nil {
		log.Printf("Read File Fail %v %v", fileName, err)
	}

	checker, err := checkstyle.New(gConfig)
	if err != nil {
		panic("New Checker Fail")
	}

	ps, err := checker.Check(fileName, file)
	if err != nil {
		log.Printf("Parse File Fail %v %v", fileName, err)
	}

	for _, p := range ps {
		fmt.Printf("%s:%v: %s\n", fileName, p.Position, p.Description)
	}
}

func checkDir(dir string) {
	filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
		if err == nil && !info.IsDir() && strings.HasSuffix(path, ".go") {
{'fraction_non_alphanumeric': 0.1746031746031746, 'fraction_numerical': 0.0, 'mean_word_length': 3.6247379454926625, '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': '491180', 'n_tokens_mistral': 891, 'n_tokens_neox': 880, 'n_words': 220}