Skip to content
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

feat: Add detection for deprecated dependencies in .library #104

Merged
merged 27 commits into from
Jul 30, 2024

Conversation

maxreichmann
Copy link
Member

@maxreichmann maxreichmann commented May 7, 2024

JIRA: CPOUI5FOUNDATION-825

+refactor: Add common xmlParser
+refactor: Remove htmlParser

The Lib.init() call detection is addressed in the following PR: #197

@maxreichmann maxreichmann changed the title feat: Add Linter for .library files feat: Add detection for deprecated dependencies in .library + library.js files May 7, 2024
@matz3 matz3 mentioned this pull request May 27, 2024
27 tasks
@maxreichmann maxreichmann changed the title feat: Add detection for deprecated dependencies in .library + library.js files feat: Add detection for deprecated dependencies in .library Jul 12, 2024
@maxreichmann maxreichmann force-pushed the feature-825-analyze-library.js-&-.library branch from 759be35 to 0cd78fa Compare July 12, 2024 12:02
d3xter666 added a commit that referenced this pull request Jul 17, 2024
JIRA: CPOUI5FOUNDATION-825

The `.library` detection is addressed in the following PR:
#104
@maxreichmann maxreichmann marked this pull request as ready for review July 17, 2024 08:26
@maxreichmann maxreichmann marked this pull request as draft July 17, 2024 08:26
@maxreichmann maxreichmann force-pushed the feature-825-analyze-library.js-&-.library branch from a7b646e to ce5dd32 Compare July 17, 2024 08:36
@maxreichmann maxreichmann marked this pull request as ready for review July 17, 2024 08:40
@maxreichmann maxreichmann requested a review from a team July 17, 2024 08:41
Copy link
Contributor

@d3xter666 d3xter666 left a comment

Choose a reason for hiding this comment

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

LGTM, but we worked in pair on that, so someone else needs to take a look, too

@maxreichmann maxreichmann requested a review from a team July 17, 2024 11:01
@matz3
Copy link
Member

matz3 commented Jul 17, 2024

When limiting the linting to just the .library, the linter fails, which might be related to @flovogt's comment about the root reader:

ui5lint --file-paths src/sap/f/.library
⚠️  Process Failed With Error

Error Message:
Resource not found: /resources/sap/f/.library

Stack Trace:
Error: Resource not found: /resources/sap/f/.library
    at lib/linter/dotLibrary/linter.js:14:23

@matz3
Copy link
Member

matz3 commented Jul 17, 2024

When there is an empty node <libraryName></libraryName>, there is an exception reported:

openui5/src/sap.f/src/sap/f/.library
0:0 error Fatal error: Cannot read properties of undefined (reading 'value')

@matz3
Copy link
Member

matz3 commented Jul 17, 2024

The library name node is looked up everywhere in the XML document, not just within the expected structure.
So putting a <libraryName>sap.ui.commons</libraryName> anywhere also leads to an error, which isn't really expected. In this case there is no conflict, as the name is not used anywhere else in the document.

Could you check how much effort it would be to really check for the right place of the dependency name in the document?
Only such a definition should be checked:

<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >
  <dependencies>
    <dependency>
      <libraryName>sap.ui.commons</libraryName>
    </dependency>
  </dependencies>
</library>

As this is not expected to cause any issues, I'm fine with the current state in case this is a high effort to implement.

@d3xter666
Copy link
Contributor

When limiting the linting to just the .library, the linter fails, which might be related to @flovogt's comment about the root reader:

ui5lint --file-paths src/sap/f/.library
⚠️  Process Failed With Error

Error Message:
Resource not found: /resources/sap/f/.library

Stack Trace:
Error: Resource not found: /resources/sap/f/.library
    at lib/linter/dotLibrary/linter.js:14:23

Fixed with a876b14

@d3xter666
Copy link
Contributor

not read properties of undefined (reading 'va

Fixed

@d3xter666
Copy link
Contributor

The library name node is looked up everywhere in the XML document, not just within the expected structure. So putting a <libraryName>sap.ui.commons</libraryName> anywhere also leads to an error, which isn't really expected. In this case there is no conflict, as the name is not used anywhere else in the document.

Could you check how much effort it would be to really check for the right place of the dependency name in the document? Only such a definition should be checked:

<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >
  <dependencies>
    <dependency>
      <libraryName>sap.ui.commons</libraryName>
    </dependency>
  </dependencies>
</library>

As this is not expected to cause any issues, I'm fine with the current state in case this is a high effort to implement.

We've managed to handle this one with 12bfaec

Copy link
Member

@matz3 matz3 left a comment

Choose a reason for hiding this comment

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

LGTM. The mentioned issue have been addressed. Just some minor remarks.

Comment on lines +14 to +18
const resource = await workspace.byPath(resourcePath);
if (!resource) {
throw new Error(`Resource not found: ${resourcePath}`);
}
dotLibraryResources.push(resource);
Copy link
Member

Choose a reason for hiding this comment

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

This is not covered by the tests

Comment on lines +26 to +31
this.#context.addLintingMessage(this.#resourcePath, {
severity: LintMessageSeverity.Error,
message,
ruleId: RULES["ui5-linter-parsing-error"],
fatal: true,
});
Copy link
Member

Choose a reason for hiding this comment

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

Not covered by unit tests

src/linter/dotLibrary/DotLibraryLinter.ts Outdated Show resolved Hide resolved
src/linter/dotLibrary/DotLibraryLinter.ts Outdated Show resolved Hide resolved
src/linter/dotLibrary/DotLibraryLinter.ts Outdated Show resolved Hide resolved
src/linter/dotLibrary/DotLibraryLinter.ts Outdated Show resolved Hide resolved
@maxreichmann maxreichmann merged commit 161f157 into main Jul 30, 2024
13 checks passed
@maxreichmann maxreichmann deleted the feature-825-analyze-library.js-&-.library branch July 30, 2024 07:49
@openui5bot openui5bot mentioned this pull request Jul 30, 2024
d3xter666 pushed a commit that referenced this pull request Jul 30, 2024
🚜 New release prepared
---


## [0.3.1](v0.3.0...v0.3.1)
(2024-07-30)


### Features

* Add detection for deprecated dependencies in .library
([#104](#104))
([161f157](161f157))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants