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

SCAN4NET-158 Make file indexing more resilient #2261

Merged
merged 3 commits into from
Nov 7, 2024

Conversation

costin-zaharia-sonarsource
Copy link
Member

Part of SCAN4NET-158

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. The exception logging is wrong, and therefore, I request changes. The other comments are nitpicks.

ServerSettings = [new("sonar.typescript.file.suffixes", ".ts,.tsx")]
};

var sut = new AdditionalFilesService(directoryWrapper, logger);
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to create the directoryWrapper and the sut, you can re-use the wrapper and sut initialized in the constructor (called once every method).

It's going to look like this, which is a bit simpler. Same in the second test.

        wrapper.EnumerateDirectories(ProjectBaseDir, "*", SearchOption.AllDirectories).Throws(_ => new DirectoryNotFoundException("Error message"));
        var analysisConfig = new AnalysisConfig
        {
            ScanAllAnalysis = true,
            LocalSettings = [],
            ServerSettings = [new("sonar.typescript.file.suffixes", ".ts,.tsx")]
        };

        var files = sut.AdditionalFiles(analysisConfig, ProjectBaseDir);

        files.Sources.Should().BeEmpty();
        files.Tests.Should().BeEmpty();
        wrapper.Received(1).EnumerateDirectories(ProjectBaseDir, "*", SearchOption.AllDirectories);
        logger.DebugMessages[0].Should().Be($"Reading directories from: '{ProjectBaseDir}'.");
        logger.DebugMessages[1].Should().MatchEquivalentOf(@"HResult: -2147024893, Exception: System.IO.DirectoryNotFoundException: Error message
   at NSubstitute.ExceptionExtensions.ExceptionExtensions.<>c__DisplayClass2_0.<Throws>b__0(CallInfo ci) *");
        logger.DebugMessages[2].Should().Be($"Reading files from: '{ProjectBaseDir}'.");
        logger.DebugMessages[3].Should().Be($"Found 0 files in: '{ProjectBaseDir}'.");
        logger.AssertSingleWarningExists($"Failed to get directories from: '{ProjectBaseDir}'.");

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, left only a small suggestion, not a blocker.

@gregory-paidis-sonarsource gregory-paidis-sonarsource dismissed martin-strecker-sonarsource’s stale review November 7, 2024 11:01

Martin is off for two days, I am taking over the PR

Copy link

sonarcloud bot commented Nov 7, 2024

@costin-zaharia-sonarsource costin-zaharia-sonarsource merged commit 3a2028d into master Nov 7, 2024
14 checks passed
@costin-zaharia-sonarsource costin-zaharia-sonarsource deleted the costin/SCAN4NET-158 branch November 7, 2024 15:07
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.

3 participants