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

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

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

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

  `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} >> #{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 :lint do
  [
    'go vet',
    'golint',
    'gosimple',
    'unused',
    'staticcheck',
    'interfacer',
    'errcheck'
  ].each do |command|
    sh "#{command} ./..."
  end

  sh 'misspell -error .'
end

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

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

  sh 'rubocop -a'
end

task :install_deps do
  sh %w[
    go get -u
    github.com/client9/misspell/cmd/misspell
    github.com/golang/lint/golint
    github.com/kisielk/errcheck
    github.com/kr/pretty
    golang.org/x/tools/cmd/goimports
    mvdan.cc/interfacer
    honnef.co/go/tools/...
  ].join ' '

  sh 'go get -d -t ./...'
end

task install: %i[install_deps test build] do
  sh 'go get ./...'
end

task default: %i[test build]

task :clean do
  sh 'git clean -dfx'
end
<commit_msg>Run aligncheck, structcheck and varcheck<commit_after>TOTAL_COVERAGE_FILE = 'coverage.txt'.freeze # This path is specified by codecov.
BIN_PATH = File.absolute_path 'bin'

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

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

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

  `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} >> #{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 :lint do
  [
    'go vet',
    'golint',
    'gosimple',
    'unused',
    'staticcheck',
    'interfacer',
    'errcheck',
    'aligncheck',
    'structcheck',
    'varcheck'
  ].each do |command|
    sh "#{command} ./..."
  end

  sh 'misspell -error .'
end

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

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

  sh 'rubocop -a'
end

task :install_deps do
  sh %w[
    go get -u
    github.com/client9/misspell/cmd/misspell
    github.com/golang/lint/golint
    github.com/kisielk/errcheck
    github.com/kr/pretty
    github.com/opennota/check/cmd/aligncheck
    github.com/opennota/check/cmd/structcheck
    github.com/opennota/check/cmd/varcheck
    golang.org/x/tools/cmd/goimports
    mvdan.cc/interfacer
    honnef.co/go/tools/...
  ].join ' '

  sh 'go get -d -t ./...'
end

task install: %i[install_deps test build] do
  sh 'go get ./...'
end

task default: %i[test build]

task :clean do
  sh 'git clean -dfx'
end

{'fraction_non_alphanumeric': 0.14701173959445038, 'fraction_numerical': 0.0026680896478121665, 'mean_word_length': 2.3354092526690393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2036346', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1429, 'n_words': 356}