Showing 87 of 247 total issues
Function updateSerializableObject
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function updateSerializableObject<T>(target: Serializable<T>, options: SerializableObjectOptions<T>): void {
const ownMeta = DataSerializerUtils.getMetadata(target);
const rootMeta = DataSerializerUtils.getRootMetadata(target.prototype);
rootMeta.knownTypes.add(target);
if (rootMeta.initializerCallback && !ownMeta.initializerCallback) {
Function callService
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
callService(call: WorkerServiceCall): Promise<WorkerServiceResponse> {
return new Promise((resolve, reject) => {
const service: Service =
this.model.findDataService(call.serviceUID) || this.model.findService(call.serviceUID);
if ((service as any)[call.method]) {
Function processRelativePositions
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public processRelativePositions<P extends Absolute2DPosition | Absolute3DPosition | GeographicalPosition>(
dataObject: DataObject,
relativePositions: Map<RelativeAngle, DataObject>,
dataFrame: DataFrame,
): Promise<DataObject> {
Function constructor
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
constructor(
x?: number,
y?: number,
z?: number,
unit?: Unit,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function swap
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
swap(subunits: Unit[], options?: UnitOptions): DerivedUnit {
if (Unit.UNITS.has(options.name)) {
return Unit.UNITS.get(options.name) as this;
}
Function merge
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public merge(frames: InOut[]): InOut {
const mergedFrame = frames[0];
const mergedObjects: Map<string, DataObject[]> = new Map();
mergedFrame.getObjects().forEach((object) => {
if (mergedObjects.get(object.uid)) {
Function createHandler
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createHandler(target: Service, p: PropertyKey): (...args: any[]) => any {
return (...args: any[]) =>
new Promise<any>((resolve, reject) => {
const uuid = uuidv4();
this._promises.set(uuid, { resolve, reject });
Function convertAsArray
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
convertAsArray(
sourceObject: Array<any>,
typeDescriptor: ArrayTypeDescriptor,
memberName: string,
serializer: Serializer,
Function createDefinition
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createDefinition(targetUnit: Unit): UnitFunctionDefinition<any, any> {
let newDefinition: UnitFunctionDefinition<any, any>;
// Get base unit
const baseUnitName = Unit.UNIT_BASES.get(this.baseName);
Function _onWorkerService
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private _onWorkerService(threadId: number, value: WorkerServiceCall): void {
const service: Service =
this.model.findDataService(value.serviceUID) || this.model.findService(value.serviceUID);
if ((service as any)[value.method]) {
const serializedParams = value.parameters;
Function midpointGeographical
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected midpointGeographical(
sphereA: Sphere<GeographicalPosition>,
sphereB: Sphere<GeographicalPosition>,
): GeographicalPosition {
const pointA = sphereA.position;
Function processObject
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public processObject(dataObject: DataObject, dataFrame: InOut): Promise<DataObject> {
return new Promise((resolve, reject) => {
const referencePromises: Array<Promise<DataObject>> = [];
const index = new Map<string, R>();
for (const relativePosition of dataObject.relativePositions) {
Function process
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public process(frame: InOut, options?: GraphOptions): Promise<InOut> {
return new Promise<InOut>((resolve, reject) => {
const processObjectPromises: Array<Promise<DataObject>> = [];
const uids = [];
const sourceUID = frame.source ? frame.source.uid : undefined;
Function onPull
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public onPull(options: PullOptions = { requestedObjects: [] }): Promise<Out> {
return new Promise<Out>((resolve, reject) => {
const service = this.model.findDataService(DataObject);
const requestPromises: Array<Promise<DataObject>> = [];
options.requestedObjects.forEach((uid) => {
Function addShape
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public addShape(shape: GraphBuilder<any, any> | GraphShape<any, any>): this {
let graph: GraphShape<any, any>;
if (shape instanceof GraphBuilder) {
graph = shape.graph;
} else {
Function processObject
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
processObject(object: DataObject): Promise<DataObject> {
return new Promise((resolve, reject) => {
const relativePositions = object.relativePositions
// For each relative position matching the type
.filter((x) => x instanceof this._relativePositionType);
Function triangulate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected triangulate<P extends AbsolutePosition>(points: P[], angles: number[]): Promise<P> {
return new Promise<P>((resolve, reject) => {
const vectors = [points[0].toVector3(), points[1].toVector3(), points[2].toVector3()];
const x1 = vectors[0].x - vectors[1].x;
Function _addServices
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private _addServices(services: any[], call: (call: WorkerServiceCall) => Promise<WorkerServiceResponse>): void {
const model = this.model as ModelGraph<any, any>;
services
.filter((service) => {
const internalService =
Function evaluateArraySelector
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected static evaluateArraySelector<T>(selector: string, value: any, subquery: QuerySelector<T>): boolean {
let result = true;
switch (selector) {
case '$in':
result = result && Array.from(value).includes(subquery[selector]);
Function _onOutput
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private _onOutput(next: { id: string; success: boolean; result?: any }): void {
if (this._promises.has(next.id)) {
const promise = this._promises.get(next.id);
if (next.success) {
if (next.result === undefined) {