<commit_before>'use strict';

import vscode = require('vscode');
import path = require('path');
import cp = require('child_process');
import iconv = require('iconv-lite');

import { window } from 'vscode';

export interface ICheckResult {
	file: string;
	line: number;
	column: [number, number];
	msg: string;
	severity: string
}

export function check(filename: string, lintOnSave = true, mlintPath = ""): Promise<ICheckResult[]> {
	var matlabLint = !lintOnSave ? Promise.resolve([]) : new Promise((resolve, reject) => {
		var filename = window.activeTextEditor.document.fileName;

		let matlabConfig = vscode.workspace.getConfiguration('matlab');

		let fileEncoding = 'utf8';

		if (matlabConfig.has('linterEncoding') && matlabConfig['linterEncoding'] != null) {
			fileEncoding = matlabConfig['linterEncoding'];
		}

		cp.execFile(
			mlintPath,
			[filename],
			{ encoding: 'buffer' },
			(err: Error, stdout, stderr) => {
				try {
					let errorsString = iconv.decode(stderr, fileEncoding);

					var errors = errorsString.split('\n');

					var ret: ICheckResult[] = [];

					errors.forEach(error => {
						var regex = /L (\d+) \(C (\d+)-?(\d+)?\): (.*)/;
						var match = regex.exec(error);

						if (match != null) {
							var [_, lineStr, startCol, endCol, msg] = match;
							var line = +lineStr;

							if (endCol == null) {
								endCol = startCol;
							}

							ret.push({ file: filename, line, column: [+startCol, +endCol], msg, severity: "warning" });
						}
					});<commit_msg>show *all* mlint messages (#23)<commit_after>'use strict';

import vscode = require('vscode');
import path = require('path');
import cp = require('child_process');
import iconv = require('iconv-lite');

import { window } from 'vscode';

export interface ICheckResult {
	file: string;
	line: number;
	column: [number, number];
	msg: string;
	severity: string
}

export function check(filename: string, lintOnSave = true, mlintPath = ""): Promise<ICheckResult[]> {
	var matlabLint = !lintOnSave ? Promise.resolve([]) : new Promise((resolve, reject) => {
		var filename = window.activeTextEditor.document.fileName;

		let matlabConfig = vscode.workspace.getConfiguration('matlab');

		let fileEncoding = 'utf8';

		if (matlabConfig.has('linterEncoding') && matlabConfig['linterEncoding'] != null) {
			fileEncoding = matlabConfig['linterEncoding'];
		}

		cp.execFile(
			mlintPath,
			['-all', filename],
			{ encoding: 'buffer' },
			(err: Error, stdout, stderr) => {
				try {
					let errorsString = iconv.decode(stderr, fileEncoding);

					var errors = errorsString.split('\n');

					var ret: ICheckResult[] = [];

					errors.forEach(error => {
						var regex = /L (\d+) \(C (\d+)-?(\d+)?\): (.*)/;
						var match = regex.exec(error);

						if (match != null) {
							var [_, lineStr, startCol, endCol, msg] = match;
							var line = +lineStr;

							if (endCol == null) {
								endCol = startCol;
							}

							ret.push({ file: filename, line, column: [+startCol, +endCol], msg, severity: "warning" });
						}
					});
{'fraction_non_alphanumeric': 0.1664478003939593, 'fraction_numerical': 0.0013131976362442547, 'mean_word_length': 3.487481590574374, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5291481', 'n_tokens_mistral': 1203, 'n_tokens_neox': 989, 'n_words': 243}