<commit_before>TOTAL_COVERAGE_FILE = 'coverage.txt'.freeze # This path is specified by codecov.
BIN_PATH = File.absolute_path 'bin'

task :deps do
  sh %w[go get -u
        github.com/alecthomas/gometalinter
        github.com/mattn/goveralls
        github.com/raviqqe/liche].join ' '
  sh 'gometalinter --install'
  sh 'go get -d -t ./...'
  sh 'gem install rake rubocop'
end

task :build do
  sh 'go build -o bin/coel src/cmd/coel/main.go'
end

task :fast_unit_test do
  sh 'go test ./...'
end

task :unit_test do
  coverage_file = "/tmp/coel-unit-test-#{Process.pid}.coverage"

  sh "echo mode: atomic > #{TOTAL_COVERAGE_FILE}"

  `go list ./src/lib/...`.split.each do |package|
    sh %W[go test
          -covermode atomic
          -coverprofile #{coverage_file}
          #{`uname -m` =~ /x86_64/ ? '-race' : ''}
          #{package}].join ' '

    verbose false do
      if File.exist? coverage_file
        sh "cat #{coverage_file} | grep -v mode: >> #{TOTAL_COVERAGE_FILE}"
        rm coverage_file
      end
    end
  end
end

task command_test: :build do
  sh 'bundler install'
  sh %W[bundler exec cucumber
        -r examples/aruba.rb
        PATH=#{BIN_PATH}:$PATH
        examples].join ' '
end

task test: %i[unit_test command_test]

task :format do
  sh 'go fix ./...'
  sh 'go fmt ./...'

  Dir.glob '**/*.go' do |file|
    sh "goimports -w #{file}"
  end

  sh 'rubocop -a'
end

task :lint do
  sh %w[gometalinter
        --disable gocyclo
        --disable vetshadow
        --enable gofmt
        --enable goimports
        --enable misspell
        ./...].join ' '
  sh 'rubocop'
  sh "liche -v #{Dir.glob('**/*.md').join ' '}"<commit_msg>Run gofmt -s in format task<commit_after>TOTAL_COVERAGE_FILE = 'coverage.txt'.freeze # This path is specified by codecov.
BIN_PATH = File.absolute_path 'bin'

task :deps do
  sh %w[go get -u
        github.com/alecthomas/gometalinter
        github.com/mattn/goveralls
        github.com/raviqqe/liche].join ' '
  sh 'gometalinter --install'
  sh 'go get -d -t ./...'
  sh 'gem install rake rubocop'
end

task :build do
  sh 'go build -o bin/coel src/cmd/coel/main.go'
end

task :fast_unit_test do
  sh 'go test ./...'
end

task :unit_test do
  coverage_file = "/tmp/coel-unit-test-#{Process.pid}.coverage"

  sh "echo mode: atomic > #{TOTAL_COVERAGE_FILE}"

  `go list ./src/lib/...`.split.each do |package|
    sh %W[go test
          -covermode atomic
          -coverprofile #{coverage_file}
          #{`uname -m` =~ /x86_64/ ? '-race' : ''}
          #{package}].join ' '

    verbose false do
      if File.exist? coverage_file
        sh "cat #{coverage_file} | grep -v mode: >> #{TOTAL_COVERAGE_FILE}"
        rm coverage_file
      end
    end
  end
end

task command_test: :build do
  sh 'bundler install'
  sh %W[bundler exec cucumber
        -r examples/aruba.rb
        PATH=#{BIN_PATH}:$PATH
        examples].join ' '
end

task test: %i[unit_test command_test]

task :format do
  sh 'go fix ./...'
  sh 'go fmt ./...'
  sh 'gofmt -s -w .'

  Dir.glob '**/*.go' do |file|
    sh "goimports -w #{file}"
  end

  sh 'rubocop -a'
end

task :lint do
  sh %w[gometalinter
        --disable gocyclo
        --disable vetshadow
        --enable gofmt
        --enable goimports
        --enable misspell
        ./...].join ' '
  sh 'rubocop'
  sh "liche -v #{Dir.glob('**/*.md').join ' '}"
{'fraction_non_alphanumeric': 0.14638500446295746, 'fraction_numerical': 0.0023802439750074383, 'mean_word_length': 2.186729857819905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '703771', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1244, 'n_words': 333}