ProcessManagerMock
has 26 functions (exceeds 20 allowed). Consider refactoring.
export class ProcessManagerMock implements Xrm.ProcessFlow.ProcessManager {
public enabledProcesses: Xrm.Page.Process[] | Xrm.ProcessFlow.ProcessDictionary;
constructor(enabledProcesses: Xrm.ProcessFlow.Process[]) {
this.enabledProcesses = enabledProcesses;
ContextMock
has 22 functions (exceeds 20 allowed). Consider refactoring.
export class ContextMock implements Xrm.GlobalContext {
public advancedConfigSetting: {[index in "MaxChildIncidentNumber" | "MaxIncidentMergeNumber"]: number };
public client: Xrm.ClientContext;
public clientUrl: string;
public currentAppName: string;
Function constructor
has 55 lines of code (exceeds 25 allowed). Consider refactoring.
constructor(components: IEntityMetadataComponents) {
this.ActivityTypeMask = components.ActivityTypeMask;
this.Attributes = components.Attributes;
this.AutoRouteToOwnerQueue = components.AutoRouteToOwnerQueue;
this.CanEnableSyncToExternalSearchIndex = components.CanEnableSyncToExternalSearchIndex;
Function createOptionSetFromParameters
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
private createOptionSetFromParameters(name: string,
value: string | number,
options: Xrm.OptionSetValue[]): XrmMock.OptionSetAttributeMock {
let num: number;
if (value !== null
Function get
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
public get(param?: string | number | Xrm.Collection.MatchingDelegate<T> | T[]): T | T[] {
if (param === undefined || param === null) {
return (this.itemCollection as T[]);
} else if (typeof param === "string") {
let attribute: T;
Function removeOption
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
public removeOption(value: number): void {
let option: OptionSetValueMock;
for (const item of this.options) {
if (item.value === value) {
option = item;
Function createOptionSetFromParameters
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
private createOptionSetFromParameters(name: string,
value: string | number,
options: Xrm.OptionSetValue[]): XrmMock.OptionSetAttributeMock {
let num: number;
if (value !== null
Function constructor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
constructor(components: ILookupControlComponents) {
super(LookupControlMock.defaultComponents(components));
this.entityTypes = components.entityTypes || [];
this.filters = components.filters || [];
this.onLookupTagHandlers = components.onLookupTagHandlers || [];
Function setFormNotification
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
public setFormNotification(message: string, level: Xrm.Page.ui.FormNotificationLevel, uniqueId: string): boolean {
let formNotificationAlreadyExists = false;
if (this.formNotifications && this.formNotifications.length) {
formNotificationAlreadyExists = this._getFormNotificationExists(this.formNotifications, uniqueId);
}
Function getIsDirty
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
public getIsDirty(): boolean {
let isDirty = false;
if (this.attributes) {
for (let i = 0; i < this.attributes.getLength(); i++) {
Function setValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
public setValue(value: number): void {
if ((this.min || this.min === 0) && this.min > value) {
throw new Error(("value cannot be below the min of " + this.min));
} else if ((this.max || this.max === 0) && this.max < value) {
throw new Error(("value cannot be above the max of " + this.max));