Skip to content

Commit 69572bf

Browse files
committed
make sure mlc output is always ordered and small tweaks
1 parent fbd650c commit 69572bf

File tree

17 files changed

+313
-308
lines changed

17 files changed

+313
-308
lines changed

.github/workflows/test-action.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,10 @@ jobs:
252252
step-name: 'Markdown Link Check'
253253
only-errors: 'false'
254254
output: 'step-md'
255-
json-filepath: './mlc-json-result-3.json'
256-
markdown-filepath: './mlc-md-result-3.md'
257255
- name: Dump outputs from previous step
258256
run: |
259257
Write-Output "${{ steps.mlc-log-parser-3.outputs.mlc-result }}"
260-
- name: Verify md file output for mlc with errors
258+
- name: Verify md step output for mlc with errors
261259
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
262260
run: |
263261
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-without-capture-errors-only.md -Raw
@@ -274,7 +272,7 @@ jobs:
274272
{
275273
Write-Output "Markdown step output matches expected Markdown."
276274
}
277-
- name: Verify md file output for mlc without errors
275+
- name: Verify md step output for mlc without errors
278276
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
279277
run: |
280278
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.md -Raw

MarkdownLinkCheckLogParser/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ dotnet_diagnostic.CA1014.severity = none # CA1014: Mark assemblies with C
9090
dotnet_diagnostic.CA1030.severity = silent # CA1030: Use events where appropriate
9191
dotnet_diagnostic.CA1032.severity = none # CA1032: Implement standard exception constructors
9292
# Globalization rules https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/globalization-warnings
93+
dotnet_diagnostic.CA1303.severity = none # CA1303: Do not pass literals as localized parameters
9394
dotnet_diagnostic.CA1308.severity = none # CA1308: Normalize strings to uppercase
9495
# Maintainability rules https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/maintainability-warnings
9596
dotnet_diagnostic.CA1508.severity = none # CA1508: Avoid dead conditional code # This one seems to flag false positives in some cases

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/CliCommands/ParseLog/ParseLogCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public async ValueTask ExecuteAsync(IConsole console)
8383
var outputMarkdownFilePath = new OutputMarkdownFilepathOption(OutputMarkdownFilepath);
8484
var outputFormats = OutputFormats.Create(outputOptions, _file, console, outputJsonFilePath, outputMarkdownFilePath);
8585

86-
using var httpClient = _httpClient ?? GitHubHttpClient.Create(authToken);
86+
using var httpClient = _httpClient ?? GitHubHttpClient.CreateHttpClient(authToken);
8787
var gitHubHttpClient = new GitHubHttpClient(httpClient);
8888
var gitHubWorkflowRunLogs = new GitHubWorkflowRunLogs(gitHubHttpClient);
8989
var stepLog = await gitHubWorkflowRunLogs.GetStepLogAsync(repo, runId, jobName, stepName);

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/GitHub/GitHubHttpClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public GitHubHttpClient(HttpClient httpClient)
99
_httpClient = httpClient.NotNull();
1010
}
1111

12-
public static HttpClient Create(GitHubAuthToken authToken)
12+
public static HttpClient CreateHttpClient(GitHubAuthToken authToken)
1313
{
1414
authToken.NotNull();
1515
var httpClient = new HttpClient
@@ -18,7 +18,7 @@ public static HttpClient Create(GitHubAuthToken authToken)
1818
};
1919
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("token", authToken);
2020
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/vnd.github.v3+json");
21-
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "markdown-link-check-log-parser");
21+
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "edumserrano/markdown-link-check-log-parser");
2222
return httpClient;
2323
}
2424

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/GitHub/Types/GitHubJobName.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ internal sealed class GitHubJobName
44
{
55
private readonly string _value;
66

7-
public GitHubJobName(string gitHubJobName)
7+
public GitHubJobName(string jobName)
88
{
9-
_value = gitHubJobName.NotNullOrWhiteSpace();
9+
_value = jobName.NotNullOrWhiteSpace();
1010
}
1111

12-
public static implicit operator string(GitHubJobName gitHubAuthToken)
12+
public static implicit operator string(GitHubJobName jobName)
1313
{
14-
return gitHubAuthToken._value;
14+
return jobName._value;
1515
}
1616

1717
public override string ToString() => (string)this;

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/GitHub/Types/GitHubRepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ internal sealed class GitHubRepository
44
{
55
private readonly string _value;
66

7-
public GitHubRepository(string gitHubRepository)
7+
public GitHubRepository(string repository)
88
{
9-
_value = gitHubRepository.NotNullOrWhiteSpace();
9+
_value = repository.NotNullOrWhiteSpace();
1010
}
1111

12-
public static implicit operator string(GitHubRepository gitHubAuthToken)
12+
public static implicit operator string(GitHubRepository repository)
1313
{
14-
return gitHubAuthToken._value;
14+
return repository._value;
1515
}
1616

1717
public override string ToString() => (string)this;

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/GitHub/Types/GitHubRunId.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ internal sealed class GitHubRunId
44
{
55
private readonly string _value;
66

7-
public GitHubRunId(string gitHubRunId)
7+
public GitHubRunId(string runId)
88
{
9-
_value = gitHubRunId.NotNullOrWhiteSpace();
9+
_value = runId.NotNullOrWhiteSpace();
1010
}
1111

12-
public static implicit operator string(GitHubRunId gitHubAuthToken)
12+
public static implicit operator string(GitHubRunId rundId)
1313
{
14-
return gitHubAuthToken._value;
14+
return rundId._value;
1515
}
1616

1717
public override string ToString() => (string)this;

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/GitHub/Types/GitHubStepName.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ internal sealed class GitHubStepName
44
{
55
private readonly string _value;
66

7-
public GitHubStepName(string gitHubStepName)
7+
public GitHubStepName(string stepName)
88
{
9-
_value = gitHubStepName.NotNullOrWhiteSpace();
9+
_value = stepName.NotNullOrWhiteSpace();
1010
}
1111

12-
public static implicit operator string(GitHubStepName gitHubAuthToken)
12+
public static implicit operator string(GitHubStepName stepaName)
1313
{
14-
return gitHubAuthToken._value;
14+
return stepaName._value;
1515
}
1616

1717
public override string ToString() => (string)this;

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/MarkdownLinkCheck/LogLines/IMarkdownLinkCheckLogLine.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace MarkdownLinkCheckLogParserCli.MarkdownLinkCheck.LogLines;
22

3+
// This is part of the Visitor pattern implement to handle the parsing of each log line of the mlc output
4+
// This interface would be equivalent to the IComponent in this example https://refactoring.guru/design-patterns/visitor/csharp/example
5+
// Also, the Handle method in this interface is equivalent to the Accept method in the IComponent interface
36
internal interface IMarkdownLinkCheckLogLine
47
{
58
void Handle(ParserState state);

MarkdownLinkCheckLogParser/src/MarkdownLinkCheckLogParserCli/MarkdownLinkCheck/MarkdownFileCheck.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public MarkdownFileCheck(string filename)
1818

1919
public bool HasErrors => ErrorCount > 0;
2020

21-
public IReadOnlyList<MarkdownLinkError> Errors => _errors;
21+
public IReadOnlyList<MarkdownLinkError> Errors => _errors.OrderBy(x => x.Link).ToList();
2222

2323
internal void AddError(string link, int statusCode)
2424
{

0 commit comments

Comments
 (0)