<commit_before>{exec, child} = require('child_process')
fs = require('fs')
Linter = require(atom.packages.getLoadedPackage('linter').path + '/lib/linter')

class LinterScalac extends Linter
	@syntax: ['source.scala']

	cmd: 'scalac'

	executablePath: ''

	linterName: 'scalac'

	options: ''

	regex: 'scala:(?<line>\\d+): ((?<error>error)|(?<warning>warning)): (?<message>(.+)\\n(.+))\\n'

	constructor: (editor) ->
		super(editor)

		@pathSubscription = atom.config.observe('linter-scalac.scalacExecutablePath', =>
			@executablePath = atom.config.get('linter-scalac.scalacExecutablePath')
		)

		@optionsSubscription = atom.config.observe('linter-scalac.scalacOptions', =>
			dotClasspath = atom.project.getPaths()[0] + '/.classpath'

			if atom.config.get('linter-scalac.scalacOptions')?
				@options = atom.config.get('linter-scalac.scalacOptions')

			if fs.existsSync(dotClasspath)
				classpath = fs.readFileSync(dotClasspath).toString().trim()
				@cwd = classpath.split(':')[0]
				@options = @options + ' -classpath "' + classpath + '"'
		)

	destroy: ->
		super
		@pathSubscription.dispose()
		@optionsSubscription.dispose()

	lintFile: (filePath, callback) ->
		command = @executablePath + '/' + @cmd + ' ' + filePath + ' ' + @options
		exec(command, cwd: @cwd, (error, stdout, stderr) => if stderr then @processMessage(stderr, callback))

module.exports = LinterScalac
<commit_msg>Check executable path before prefixing cmd<commit_after>{exec, child} = require('child_process')
path = require('path')
fs = require('fs')
Linter = require(atom.packages.getLoadedPackage('linter').path + '/lib/linter')

class LinterScalac extends Linter
	@syntax: ['source.scala']

	cmd: 'scalac'

	executablePath: ''

	linterName: 'scalac'

	options: ''

	regex: 'scala:(?<line>\\d+): ((?<error>error)|(?<warning>warning)): (?<message>(.+)\\n(.+))\\n'

	constructor: (editor) ->
		super(editor)

		@pathSubscription = atom.config.observe('linter-scalac.scalacExecutablePath', =>
			@executablePath = atom.config.get('linter-scalac.scalacExecutablePath')
		)

		@optionsSubscription = atom.config.observe('linter-scalac.scalacOptions', =>
			dotClasspath = atom.project.getPaths()[0] + '/.classpath'

			if atom.config.get('linter-scalac.scalacOptions')?
				@options = atom.config.get('linter-scalac.scalacOptions')

			if fs.existsSync(dotClasspath)
				classpath = fs.readFileSync(dotClasspath).toString().trim()
				@cwd = classpath.split(':')[0]
				@options = @options + ' -classpath "' + classpath + '"'
		)

	destroy: ->
		super
		@pathSubscription.dispose()
		@optionsSubscription.dispose()

	lintFile: (filePath, callback) ->
		if @executablePath
			command = @executablePath + '/' + @cmd
		else
			command = @cmd
		command += ' ' + filePath + ' ' + @options
		exec(command, cwd: @cwd, (error, stdout, stderr) => if stderr then @processMessage(stderr, callback))

module.exports = LinterScalac

{'fraction_non_alphanumeric': 0.17977915804002761, 'fraction_numerical': 0.0013802622498274672, 'mean_word_length': 4.751984126984127, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '5252534', 'n_tokens_mistral': 1090, 'n_tokens_neox': 992, 'n_words': 163}