Skip to content

fix(concerto-cto): avoid spurious newlines when decorators array is empty (closes #1647) - #1648

Open
Ashu-213 wants to merge 1 commit into
accordproject:mainfrom
Ashu-213:fix-printer-empty-decorators
Open

Ashu-213 wants to merge 1 commit into
accordproject:mainfrom
Ashu-213:fix-printer-empty-decorators

Conversation

@Ashu-213

Copy link
Copy Markdown

Closes #1647

When AST metamodel objects contain empty decorators: [] arrays, Printer.toCTO previously injected spurious leading newlines before declarations and empty indented lines before properties and map entries. This PR ensures that empty decorators arrays are handled cleanly without injecting extra whitespace or blank lines.

Changes

  • Added an empty check in decoratorsFromMetaModel to return '' if !mm || mm.length === 0.
  • Added guards in propertyFromMetaModel, mapFromMetaModel, and declFromMetaModel to check decorators && decorators.length > 0 before printing decorators.
  • Added unit tests in packages/concerto-cto/test/printer.js verifying clean CTO output when decorators: [] is present on declarations, properties, and maps.

Flags

  • None.

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

…mpty (closes accordproject#1647)

Signed-off-by: ashup <ashuptdr4@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 19:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@mira-accord-project

Copy link
Copy Markdown

Thank you for this fix, Ashu-213, and for opening the matching issue first. Guarding the decorators arrays in the CTO printer and adding tests for both declarations and map entries is a clear change. A maintainer, Jonathan Casey or Jamie Shorten, has been asked to review it, and we aim to give a first review within two business days. CI is waiting for approval from a maintainer to run on this first-time contribution, and we will approve it once the maintainers have looked at the change. Thanks again for the contribution.


Posted automatically by Mira, an Accord Project agent. A maintainer will follow up; they make the decisions on this.

@mira-accord-project mira-accord-project Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this fix, @Ashu-213: it is small, well scoped and does what #1647 asks. The empty-array guard in decoratorsFromMetaModel and the length checks at the declaration, property, map key/value and model-level call sites now stop empty decorators: [] arrays producing stray newlines and indentation. Output for non-empty and omitted decorators is unchanged, so there is no compatibility concern. Both new tests exercise the empty-array case (including an exact-string check for maps) and would fail on the old code, and CI is green. I have no changes to request; this is ready for a maintainer's approval.

No problems found.


Automated review by Mira, an Accord Project agent, at f5fedec. Findings are labelled blocking, should-fix or nit; a maintainer makes the final call.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(concerto-cto): Printer.toCTO injects extra blank lines when decorators array is empty

2 participants