diff --git a/lib/index.js b/lib/index.js index fe8cd25..1d5cab3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -198,16 +198,23 @@ export default { // Execute the Code Climate CLI, parse the results, and emit them to the // Linter package as warnings. The Linter package handles the styling. + + // eslint-disable-next-line no-console + console.log(`Running codeclimate: ${this.executablePath} ${execArgs.join(' ')}`); let result; try { result = await Helpers.exec(this.executablePath, execArgs, execOpts); } catch (e) { notifyError(e, `${this.executablePath} ${execArgs.join(' ')}`); + // eslint-disable-next-line no-console + console.error('Error running codeclimate:', e); return null; } // Handle unique spawning: killed execs will return null if (result === null) { + // eslint-disable-next-line no-console + console.error('null result from exec'); return null; } diff --git a/package.json b/package.json index bfb45e9..9879a21 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "devDependencies": { "eslint": "^4.6.0", "eslint-config-airbnb-base": "^12.0.0", - "eslint-plugin-import": "^2.7.0" + "eslint-plugin-import": "^2.7.0", + "jasmine-fix": "^1.3.1" }, "scripts": { "lint": "eslint .", diff --git a/spec/.eslintrc.js b/spec/.eslintrc.js index 47ac7cc..3dc3525 100644 --- a/spec/.eslintrc.js +++ b/spec/.eslintrc.js @@ -1,7 +1,7 @@ module.exports = { env: { - jasmine: true, atomtest: true, + jasmine: true, }, rules: { "import/no-extraneous-dependencies": [ diff --git a/spec/linter-codeclimate-spec.js b/spec/linter-codeclimate-spec.js index 1f597a0..5473e39 100644 --- a/spec/linter-codeclimate-spec.js +++ b/spec/linter-codeclimate-spec.js @@ -1,40 +1,43 @@ 'use babel'; +// eslint-disable-next-line no-unused-vars +import { it, fit, wait, beforeEach, afterEach } from 'jasmine-fix'; import { join } from 'path'; +const { lint } = require('../lib/index.js').provideLinter(); + const fixturesPath = join(__dirname, 'fixtures'); const coolCodePath = join(fixturesPath, 'cool_code.rb'); -const TIMEOUT = process.env.CI ? 60000 : 10000; -describe('The codeclimate provider for Linter', () => { - const { lint } = require('../lib/index.js').provideLinter(); +// Codeclimate can sometimes be quite slow (especially in a CI environment) +jasmine.getEnv().defaultTimeoutInterval = 60 * 1000; // 60 seconds - beforeEach(() => { +describe('The codeclimate provider for Linter', () => { + beforeEach(async () => { atom.workspace.destroyActivePaneItem(); - - waitsForPromise(() => - Promise.all([ - atom.packages.activatePackage('linter-codeclimate'), - ])); + await atom.packages.activatePackage('linter-codeclimate'); }); - it('works with a valid .codeclimate.yml file', () => - waitsForPromise( - { timeout: TIMEOUT }, - () => - atom.workspace.open(coolCodePath).then(editor => lint(editor)).then((messages) => { - expect(messages[0].severity).toBe('warning'); - expect(messages[0].excerpt).toBe('RUBOCOP: Unused method argument - ' + - "`bar`. If it's necessary, use `_` or `_bar` as an argument name to " + - "indicate that it won't be used. You can also write as `foo(*)` if " + - "you want the method to accept any arguments but don't care about " + - 'them. [Rubocop/Lint/UnusedMethodArgument]'); - expect(messages[0].description).toBeDefined(); - expect(messages[0].reference).not.toBeDefined(); - expect(messages[0].icon).not.toBeDefined(); - expect(messages[0].solutions).not.toBeDefined(); - expect(messages[0].location.file).toBe(coolCodePath); - expect(messages[0].location.position).toEqual([[1, 11], [1, 14]]); - }), - )); + it('works with a valid .codeclimate.yml file', async () => { + // eslint-disable-next-line no-console + console.log('Started the spec...'); + const editor = await atom.workspace.open(coolCodePath); + const messages = await lint(editor); + // eslint-disable-next-line no-console + console.log('Messages: ', JSON.stringify(messages, null, ' ')); + + expect(messages.length).toBe(1); + expect(messages[0].severity).toBe('warning'); + expect(messages[0].excerpt).toBe('RUBOCOP: Unused method argument - ' + + "`bar`. If it's necessary, use `_` or `_bar` as an argument name to " + + "indicate that it won't be used. You can also write as `foo(*)` if " + + "you want the method to accept any arguments but don't care about " + + 'them. [Rubocop/Lint/UnusedMethodArgument]'); + expect(messages[0].description).toBeDefined(); + expect(messages[0].reference).not.toBeDefined(); + expect(messages[0].icon).not.toBeDefined(); + expect(messages[0].solutions).not.toBeDefined(); + expect(messages[0].location.file).toBe(coolCodePath); + expect(messages[0].location.position).toEqual([[1, 11], [1, 14]]); + }); });