Skip to content

Lint xml output is invalid #14659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OrangeDog opened this issue Jun 4, 2019 · 11 comments
Closed

Lint xml output is invalid #14659

OrangeDog opened this issue Jun 4, 2019 · 11 comments

Comments

@OrangeDog
Copy link

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [x] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

No.

Description

As there's no way to specify output to a file (#4959) the only option is to redirect stdout. However, if there are multiple apps the checkstyle (and other formats) generate multiple xml documents.

🔬 Minimal Reproduction

From a new project run

ng lint --format=checkstyle >checkstyle-result.xml

🔥 Exception or Error

The output is invalid, being a concatenation of multiple documents:

<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"><file name=".../src/environments/environment.ts"></file><file name=".../src/app/app.component.ts"></file><file name=".../src/app/app.module.ts"></file><file name=.../src/main.ts"></file><file name=".../src/polyfills.ts"></file><file name=".../src/test.ts"></file><file name=".../src/app/app.component.spec.ts"></file><file name=".../src/environments/environment.prod.ts"></file></checkstyle>
<?xml version="1.0" encoding="utf-8"?><checkstyle version="4.3"><file name=".../e2e/app.po.ts"></file><file name=".../e2e/app.e2e-spec.ts"></file></checkstyle>

🌍 Your Environment


Angular CLI: 8.0.1
Node: 10.15.3
OS: win32 x64
Angular: 8.0.0
... common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.1
@angular-devkit/build-angular     0.800.1
@angular-devkit/build-optimizer   0.800.1
@angular-devkit/build-webpack     0.800.1
@angular-devkit/core              8.0.1
@angular-devkit/schematics        8.0.1
@angular/cli                      8.0.1
@ngtools/webpack                  8.0.1
@schematics/angular               8.0.1
@schematics/update                0.800.1
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0
@OrangeDog
Copy link
Author

See also #4959 (comment)

@alan-agius4 alan-agius4 added area: @angular-devkit/build-angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken labels Jun 4, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jun 4, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jun 4, 2019
@alan-agius4
Copy link
Collaborator

alan-agius4 commented Jun 4, 2019

Hi, as a workaround you can lint a single project by passing the project as an argument.
Example

ng lint <project-name> --format=checkstyle >checkstyle-result.xml

@OrangeDog
Copy link
Author

As another workaround you can pipe to split.

ng lint --format=checkstyle | split -l 1 - checkstyle.xml.

@mgechev
Copy link
Member

mgechev commented Jun 11, 2019

Not sure if the CLI is the right place to address the issue. Maybe tslint's XML reporter is the one to handle the behavior?

@clydin
Copy link
Member

clydin commented Jun 12, 2019

ng lint is a multi-project command. It runs the lint target for all projects in the workspace. The issue is there is no first-class support within the builders for this so the CLI runs each target sequentially and output of each is concatenated. This works for human consumption but in the case of a structured output (XML in this case but JSON would have the same problem) the end result is invalid.

@mgechev
Copy link
Member

mgechev commented Jun 13, 2019

In such a case, it's on us to fix the issue.

@bohni
Copy link

bohni commented Jul 23, 2019

@OrangeDog
Piping to split loses the information of the exit code of ng lint.
So e.g. maven-fronted-plugin will no longer break the build

@OrangeDog
Copy link
Author

@bohni you can set pipefail if you want that behaviour.
Fortunately I don't want it to break the build. The point of having xml output is for a further process to evaluate the build health.

@jkroepke
Copy link

@mgechev Any news on this issues?

We have this same issue with JSON format...
Or output looks like:

[{
 ...
}]
[{
 ...
}]

which results into any invalid JSON.

@alan-agius4
Copy link
Collaborator

Closing since the TSLint builder is deprecated as part of the TSLint deprecation.

More info https://blog.angular.io/version-11-of-angular-now-available-74721b7952f7

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants