-
Notifications
You must be signed in to change notification settings - Fork 76
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
fix: limit data model fetching to models folder #14625
Conversation
📝 WalkthroughWalkthroughThe pull request involves significant changes to schema file handling in the Changes
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14625 +/- ##
=======================================
Coverage 95.76% 95.76%
=======================================
Files 1914 1914
Lines 24947 24947
Branches 2855 2855
=======================================
Hits 23890 23890
Misses 799 799
Partials 258 258 ☔ View full report in Codecov by Sentry. |
….com/Altinn/altinn-studio into limit-datamodel-search-to-models-dir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Med min begrensede C#-kunnskap ser i hvert fall alt i orden ut her.
Feedback from @Konrad-Simso: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, works as expected 👍
I do have 2 comments when it comes to pathing.
backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs
Outdated
Show resolved
Hide resolved
backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs (1)
1003-1013
: Consider using LINQ for better readability.The method could be simplified using LINQ's
Select
andToList
methods.Apply this diff to use LINQ:
private List<AltinnCoreFile> MapFilesToAltinnCoreFiles(IEnumerable<string> schemaFiles) { - List<AltinnCoreFile> altinnCoreSchemaFiles = new(); - - foreach (string file in schemaFiles) - { - altinnCoreSchemaFiles.Add(AltinnCoreFile.CreateFromPath(file, RepositoryDirectory)); - } - - return altinnCoreSchemaFiles; + return schemaFiles + .Select(file => AltinnCoreFile.CreateFromPath(file, RepositoryDirectory)) + .ToList(); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
backend/src/Designer/Controllers/RepositoryController.cs
(1 hunks)backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- backend/src/Designer/Controllers/RepositoryController.cs
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Run dotnet build and test (macos-latest)
- GitHub Check: Run dotnet build and test (windows-latest)
- GitHub Check: Build environment and run e2e test
- GitHub Check: Run dotnet build and test (ubuntu-latest)
- GitHub Check: Run integration tests against actual gitea and db
- GitHub Check: Analyze
🔇 Additional comments (2)
backend/src/Designer/Infrastructure/GitRepository/AltinnAppGitRepository.cs (2)
60-61
: Rename constants to match past review suggestions.The constants should be renamed to maintain consistency with past review feedback.
Apply this diff to rename the constants:
- private const string SchemaFilePatternJson = "*.schema.json"; - private const string SchemaFilePatternXsd = "*.xsd"; + private const string SchemaFilesPatternJson = "*.schema.json"; + private const string SchemaFilesPatternXsd = "*.xsd";
980-1001
: Improve path construction for schema files.The path construction should be simplified using
Path.Combine
as suggested in past review comments.Apply this diff to improve the path construction:
- string schemaFilesPath = Path.Combine(ModelFolderPath, schemaFilesPattern); - IEnumerable<string> schemaFiles; - - try - { - schemaFiles = FindFiles(new[] { schemaFilesPath }); - } + IEnumerable<string> schemaFiles; + try + { + schemaFiles = FindFiles(new[] { Path.Combine(ModelFolderPath, schemaFilesPattern) }); + }
Description
Makes a modification to the
GetSchemaFiles
method inAltinnAppGitRepository
, so it only looks for datamodels in theApp/models/
path. This prevents Studio from showing and editing data models not in themodels
directory.Related Issue(s)
Video after fix
model-outside-models.mp4
Verification
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation