Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import chalk from 'chalk';
import { Reporter, MutantResult, MutantStatus, ScoreResult } from 'stryker-api/report';
import { Position, StrykerOptions } from 'stryker-api/core';
import ClearTextScoreTable from './ClearTextScoreTable';
import * as os from 'os';
import { tokens } from 'typed-inject';
import { commonTokens } from 'stryker-api/plugin';
import { Logger } from 'stryker-api/logging';
export default class ClearTextReporter implements Reporter {
public static inject = tokens(commonTokens.logger, commonTokens.options);
constructor(private readonly log: Logger, private readonly options: StrykerOptions) {
this.configConsoleColor();
}
private readonly out: NodeJS.WritableStream = process.stdout;
private writeLine(output?: string) {
this.out.write(`${output || ''}${os.EOL}`);
}
private configConsoleColor() {
if (!this.options.allowConsoleColors) {
chalk.level = 0; // All colors disabled
}
}
import * as os from 'os';
import { Position, StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens } from '@stryker-mutator/api/plugin';
import { MutantResult, MutantStatus, mutationTestReportSchema, Reporter } from '@stryker-mutator/api/report';
import { calculateMetrics } from 'mutation-testing-metrics';
import { tokens } from 'typed-inject';
import chalk = require('chalk');
import ClearTextScoreTable from './ClearTextScoreTable';
export default class ClearTextReporter implements Reporter {
public static inject = tokens(commonTokens.logger, commonTokens.options);
constructor(private readonly log: Logger, private readonly options: StrykerOptions) {
this.configConsoleColor();
}
private readonly out: NodeJS.WritableStream = process.stdout;
private writeLine(output?: string) {
this.out.write(`${output || ''}${os.EOL}`);
}
private configConsoleColor() {
if (!this.options.allowConsoleColors) {
chalk.level = 0; // All colors disabled
}
}
};
private readonly provideLogger = (): Logger => {
return this.logger;
};
private readonly provideOptions = () => {
return this.options;
};
private readonly provideMutatorDescriptor = () => {
return this.mutatorDescriptor;
};
public pluginResolver: sinon.SinonStubbedInstance;
public options: StrykerOptions;
public mutatorDescriptor: MutatorDescriptor;
public logger: sinon.SinonStubbedInstance;
public injector: Injector = rootInjector
.provideValue(commonTokens.getLogger, this.provideLogger)
.provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
.provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
.provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient)
.provideFactory(commonTokens.mutatorDescriptor, this.provideMutatorDescriptor, Scope.Transient);
public reset() {
this.mutatorDescriptor = factory.mutatorDescriptor();
this.options = factory.strykerOptions();
this.logger = factory.logger();
this.pluginResolver = {
resolve: sinon.stub(),
resolveAll: sinon.stub()
};
}
}
private readonly provideLogger = (): Logger => {
return this.logger;
}
private readonly provideConfig = () => {
const config = new Config();
config.set(this.options);
return config;
}
private readonly provideOptions = () => {
return this.options;
}
public pluginResolver: sinon.SinonStubbedInstance;
public options: StrykerOptions;
public logger: sinon.SinonStubbedInstance;
public injector: Injector = rootInjector
.provideValue(commonTokens.getLogger, this.provideLogger)
.provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
.provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
.provideFactory(commonTokens.config, this.provideConfig, Scope.Transient)
.provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient);
public reset() {
this.options = factory.strykerOptions();
this.logger = factory.logger();
this.pluginResolver = {
resolve: sinon.stub(),
resolveAll: sinon.stub()
};
}
}
config.set(this.options);
return config;
}
private readonly provideOptions = () => {
return this.options;
}
public pluginResolver: sinon.SinonStubbedInstance;
public options: StrykerOptions;
public logger: sinon.SinonStubbedInstance;
public injector: Injector = rootInjector
.provideValue(commonTokens.getLogger, this.provideLogger)
.provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
.provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
.provideFactory(commonTokens.config, this.provideConfig, Scope.Transient)
.provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient);
public reset() {
this.options = factory.strykerOptions();
this.logger = factory.logger();
this.pluginResolver = {
resolve: sinon.stub(),
resolveAll: sinon.stub()
};
}
}
export const testInjector = new TestInjector();
testInjector.reset();
}
private readonly provideConfig = () => {
const config = new Config();
config.set(this.options);
return config;
}
private readonly provideOptions = () => {
return this.options;
}
public pluginResolver: sinon.SinonStubbedInstance;
public options: StrykerOptions;
public logger: sinon.SinonStubbedInstance;
public injector: Injector = rootInjector
.provideValue(commonTokens.getLogger, this.provideLogger)
.provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
.provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
.provideFactory(commonTokens.config, this.provideConfig, Scope.Transient)
.provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient);
public reset() {
this.options = factory.strykerOptions();
this.logger = factory.logger();
this.pluginResolver = {
resolve: sinon.stub(),
resolveAll: sinon.stub()
};
}
}
export const testInjector = new TestInjector();
testInjector.reset();
return this.logger;
};
private readonly provideOptions = () => {
return this.options;
};
private readonly provideMutatorDescriptor = () => {
return this.mutatorDescriptor;
};
public pluginResolver: sinon.SinonStubbedInstance;
public options: StrykerOptions;
public mutatorDescriptor: MutatorDescriptor;
public logger: sinon.SinonStubbedInstance;
public injector: Injector = rootInjector
.provideValue(commonTokens.getLogger, this.provideLogger)
.provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
.provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
.provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient)
.provideFactory(commonTokens.mutatorDescriptor, this.provideMutatorDescriptor, Scope.Transient);
public reset() {
this.mutatorDescriptor = factory.mutatorDescriptor();
this.options = factory.strykerOptions();
this.logger = factory.logger();
this.pluginResolver = {
resolve: sinon.stub(),
resolveAll: sinon.stub()
};
}
}
export const testInjector = new TestInjector();
private readonly provideOptions = () => {
return this.options;
};
private readonly provideMutatorDescriptor = () => {
return this.mutatorDescriptor;
};
public pluginResolver: sinon.SinonStubbedInstance;
public options: StrykerOptions;
public mutatorDescriptor: MutatorDescriptor;
public logger: sinon.SinonStubbedInstance;
public injector: Injector = rootInjector
.provideValue(commonTokens.getLogger, this.provideLogger)
.provideFactory(commonTokens.logger, this.provideLogger, Scope.Transient)
.provideFactory(commonTokens.options, this.provideOptions, Scope.Transient)
.provideFactory(commonTokens.pluginResolver, this.providePluginResolver, Scope.Transient)
.provideFactory(commonTokens.mutatorDescriptor, this.provideMutatorDescriptor, Scope.Transient);
public reset() {
this.mutatorDescriptor = factory.mutatorDescriptor();
this.options = factory.strykerOptions();
this.logger = factory.logger();
this.pluginResolver = {
resolve: sinon.stub(),
resolveAll: sinon.stub()
};
}
}
export const testInjector = new TestInjector();
testInjector.reset();
import { Config, ConfigEditor } from '@stryker-mutator/api/config';
import { commonTokens, PluginKind, PluginResolver } from '@stryker-mutator/api/plugin';
import { tokens } from 'typed-inject';
import { coreTokens } from '../di';
import { PluginCreator } from '../di/PluginCreator';
/**
* Class that applies all config editor plugins
*/
export class ConfigEditorApplier implements ConfigEditor {
public static inject = tokens(commonTokens.pluginResolver, coreTokens.pluginCreatorConfigEditor);
constructor(private readonly pluginResolver: PluginResolver, private readonly pluginCreator: PluginCreator) {}
public edit(config: Config): void {
this.pluginResolver.resolveAll(PluginKind.ConfigEditor).forEach(plugin => {
const configEditor = this.pluginCreator.create(plugin.name);
configEditor.edit(config);
});
}
}
import { Config, ConfigEditor } from 'stryker-api/config';
import { tokens } from 'typed-inject';
import { PluginResolver, PluginKind, commonTokens } from 'stryker-api/plugin';
import { PluginCreator } from '../di/PluginCreator';
import { coreTokens } from '../di';
/**
* Class that applies all config editor plugins
*/
export class ConfigEditorApplier implements ConfigEditor {
public static inject = tokens(commonTokens.pluginResolver, coreTokens.pluginCreatorConfigEditor);
constructor(private readonly pluginResolver: PluginResolver,
private readonly pluginCreator: PluginCreator) { }
public edit(config: Config): void {
this.pluginResolver.resolveAll(PluginKind.ConfigEditor).forEach(plugin => {
const configEditor = this.pluginCreator.create(plugin.name);
configEditor.edit(config);
});
}
}