Skip to content

Commit

Permalink
chore: fixed code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
danielduarte committed Sep 9, 2023
1 parent e771098 commit 094ba15
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 42 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p style="text-align: center"><a href="https://danielduarte.github.io/flowed/"><img width="445" height="100" src="./doc/flowed-logo.svg" alt="Flowed Logo"></a></p>
<p style="text-align: center">A fast and reliable flow engine for orchestration and more uses in <em>Node.js</em>, <em>Deno</em> and the browser.</p>
<p style="text-align: center">
<p align="center"><a href="https://danielduarte.github.io/flowed/"><img width="445" height="100" src="./doc/flowed-logo.svg" alt="Flowed Logo"></a></p>
<p align="center">A fast and reliable flow engine for orchestration and more uses in <em>Node.js</em>, <em>Deno</em> and the browser.</p>
<p align="center">
<a href="https://github.com/danielduarte/flowed/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/flowed?color=%23007ec6" alt="License"></a>
<a href="https://www.npmjs.com/package/flowed"><img src="https://img.shields.io/npm/v/flowed" alt="NPM Package Version"></a>
<a href="https://app.fossa.com/attribution/e587cd9b-f7f8-4fa6-88b1-f81832d9ce07"><img src="https://app.fossa.com/api/projects/custom%2B13599%2Fgithub.com%2Fdanielduarte%2Fflowed.svg?type=shield" alt="FOSSA Status"></a>
Expand Down
5 changes: 3 additions & 2 deletions src/engine/flow-run-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export class FlowRunStatus {
// To be used later to check if expectedResults can be fulfilled.
this.taskProvisions = Array.from(new Set(provisions));

this.options = Object.assign({}, this.spec.configs ?? {}, this.spec.options ?? {});
this.options = { ...this.spec.configs, ...this.spec.options };

if (Object.prototype.hasOwnProperty.call(this.spec, 'configs')) {
this.flow.log({ m: "DEPRECATED: 'configs' field in flow spec. Use 'options' instead.", l: 'w' });
}
Expand Down Expand Up @@ -174,7 +175,7 @@ export class FlowRunStatus {
taskStatuses: {},
};

const serializableContext = Object.assign({}, this.context);
const serializableContext = { ...this.context };
delete serializableContext.$flowed;
serialized.context = JSON.parse(JSON.stringify(serializableContext));

Expand Down
6 changes: 3 additions & 3 deletions src/engine/flow-state/flow-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ export abstract class FlowState implements IFlow {
public static formatDebugMessage({ n, m, l, e }: { n?: number; m: string; mp?: ValueMap; l?: string; e?: string }): string {
const levelIcon = l === 'w' ? '⚠️ ' : '';
const eventIcons = { FS: '▶ ', FF: '✔ ', TS: ' ‣ ', TF: ' ✓ ', FC: ' ⓘ ', FT: '◼ ', FP: '⏸ ' };
let eventIcon = (eventIcons as any)[e || ''] ?? ''; // eslint-disable-line @typescript-eslint/no-explicit-any
if (e === 'TF' && ['e', 'f'].includes(l || '')) {
let eventIcon = (eventIcons as any)[e ?? ''] ?? ''; // eslint-disable-line @typescript-eslint/no-explicit-any
if (e === 'TF' && ['e', 'f'].includes(l ?? '')) {
eventIcon = ' ✗';
} else if (e === 'FF' && ['e', 'f'].includes(l || '')) {
} else if (e === 'FF' && ['e', 'f'].includes(l ?? '')) {
eventIcon = '✘';
}
const icon = levelIcon + eventIcon;
Expand Down
3 changes: 1 addition & 2 deletions test/edge-cases.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from 'chai';
import { FlowManager, ValueMap } from '../src';
import { Task } from '../src';
import { FlowManager, ValueMap, Task } from '../src';

describe('edge cases', () => {
it('manually provide unexpected requirement to task must throw an error', async () => {
Expand Down
5 changes: 2 additions & 3 deletions test/examples-inline/microservices.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ValueMap } from '../../src';
import { FlowManager } from '../../src';
import { ValueMap, FlowManager } from '../../src';
import { ExampleFunction } from '../examples/types';

const callMicroservice = (params: ValueMap) => {
Expand All @@ -23,7 +22,7 @@ const callMicroservice = (params: ValueMap) => {
};

const simpleMerge = (params: ValueMap) => ({
result: Object.assign({}, params.obj1, params.obj2),
result: { ...params.obj1, ...params.obj2 },
});

// noinspection JSUnusedGlobalSymbols
Expand Down
3 changes: 1 addition & 2 deletions test/examples-inline/pythagoras.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ValueMap } from '../../src';
import { FlowManager } from '../../src';
import { ValueMap, FlowManager } from '../../src';
import { ExampleFunction } from '../examples/types';

// Example of named function used as resolver
Expand Down
3 changes: 1 addition & 2 deletions test/examples/apparent-circular-deps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ValueMap } from '../../src';
import { FlowManager } from '../../src';
import { ValueMap, FlowManager } from '../../src';
import { ExampleFunction } from './types';

class DummyResolver {
Expand Down
3 changes: 1 addition & 2 deletions test/examples/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ValueMap } from '../../src';
import { FlowManager } from '../../src';
import { ValueMap, FlowManager } from '../../src';
import { ExampleFunction } from './types';

class DummyResolver {
Expand Down
5 changes: 2 additions & 3 deletions test/examples/microservices.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ValueMap } from '../../src';
import { FlowManager } from '../../src';
import { ValueMap, FlowManager } from '../../src';
import { ExampleFunction } from './types';

class CallMicroservice {
Expand Down Expand Up @@ -27,7 +26,7 @@ class CallMicroservice {
class SimpleMerge {
public async exec(params: ValueMap): Promise<ValueMap> {
return {
result: Object.assign({}, params.obj1, params.obj2),
result: { ...params.obj1, ...params.obj2 },
};
}
}
Expand Down
3 changes: 1 addition & 2 deletions test/examples/pythagoras.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ValueMap } from '../../src';
import { FlowManager } from '../../src';
import { ValueMap, FlowManager } from '../../src';
import { ExampleFunction } from './types';

class Sqr {
Expand Down
3 changes: 1 addition & 2 deletions test/examples/sync-async.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ValueMap } from '../../src';
import { FlowManager } from '../../src';
import { ValueMap, FlowManager } from '../../src';
import { ExampleFunction } from './types';

class TimerResolver {
Expand Down
4 changes: 1 addition & 3 deletions test/flow-manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { expect } from 'chai';
import { TaskResolverMap, ValueMap } from '../src';
import { FlowManager } from '../src';
import { FlowSpec } from '../src';
import { TaskResolverMap, ValueMap, FlowManager, FlowSpec } from '../src';

class DummyResolver {
public async exec(): Promise<ValueMap> {
Expand Down
3 changes: 1 addition & 2 deletions test/flow-pausing.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';
import rawDebug from '../src/debug';
import { ValueMap } from '../src';
import { Flow, Task } from '../src';
import { ValueMap, Flow, Task } from '../src';
const debug = rawDebug('test');

describe('the flow', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/flow-stopping.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from 'chai';
import { ValueMap } from '../src';
import { Flow, Task } from '../src';
import { ValueMap, Flow, Task } from '../src';

describe('the flow', () => {
const text1 = '(text1)';
Expand Down
3 changes: 1 addition & 2 deletions test/resolver-library-builtin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from 'chai';
import { ValueMap } from '../src';
import { FlowManager } from '../src';
import { ValueMap, FlowManager } from '../src';

describe('the ResolverLibrary', () => {
it('runs noop resolver without mapping', () => {
Expand Down
4 changes: 1 addition & 3 deletions test/resolver-library.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { expect } from 'chai';
import { Task, ValueMap, WaitResolver } from '../src';
import { FlowManager } from '../src';
import { Task, ValueMap, WaitResolver, FlowManager, TaskResolver } from '../src';
import * as ResolverLibrary from '../src/resolver-library';
import { TaskResolver } from '../src';
import rawDebug from '../src/debug';
const debug = rawDebug('test');

Expand Down
3 changes: 1 addition & 2 deletions test/serialization.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';
import rawDebug from '../src/debug';
import { Flow, ValueMap } from '../src';
import { Task } from '../src';
import { Flow, ValueMap, Task } from '../src';
const debug = rawDebug('test');

describe('a flow state can be', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/task-repeater.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';
import rawDebug from '../src/debug';
import { ValueMap } from '../src';
import { FlowManager } from '../src';
import { ValueMap, FlowManager } from '../src';
import * as ResolverLibrary from '../src/resolver-library';
const debug = rawDebug('test');

Expand Down

0 comments on commit 094ba15

Please sign in to comment.