Skip to content

Refactor: Remove unnecessary object spread in conditionalGeneration.js #1911

@Satya900

Description

@Satya900

Description

I noticed a small code smell in
apps/generator/lib/conditionalGeneration.js.
There is an object literal being spread inside another object literal unnecessarily.


Location

File: apps/generator/lib/conditionalGeneration.js
Lines: ~113–116


Current Code

const source = jmespath.search({
  ...asyncapiDocument.json(),
  ...{
    server: server ? server.json() : undefined,
  },
}, subject);

Proposed Change

We can directly define the property instead of creating a temporary object and spreading it.

const source = jmespath.search({
  ...asyncapiDocument.json(),
  server: server ? server.json() : undefined,
}, subject);

Benefits

  • Improves code readability
  • Removes a redundant operation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions