Skip to content

Commit

Permalink
Update all docs links
Browse files Browse the repository at this point in the history
  • Loading branch information
dicko2 committed Nov 18, 2024
1 parent 53aef96 commit 3b73b74
Show file tree
Hide file tree
Showing 59 changed files with 98 additions and 47 deletions.
2 changes: 2 additions & 0 deletions doc/AG0001.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0001

Type: Code Smell

https://agoda-com.github.io/standards-c-sharp/di/attribute-based-registration.html

Direct usage of `DependencyResolver` creates tight coupling and makes code harder to test. Dependencies should be explicitly declared through constructor injection, which promotes:

- Better testability through clear dependency declaration
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0003.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0003

Type: Code Smell

https://agoda-com.github.io/standards-c-sharp/services/framework-abstractions.html

Passing `System.Web.HttpContext` as a parameter creates tight coupling to the web infrastructure and makes unit testing significantly more difficult. Instead, pass only the specific HttpContext properties that your code actually needs.

#### Don't
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0004.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0004

Type: Bug

https://agoda-com.github.io/standards-c-sharp/reflection/hard-coded-strings.html

Hard-coded strings to identify namespaces and types make refactoring risky and move type resolution errors from compile-time to runtime. Always use the `typeof` operator to reference types, which provides compile-time safety.

#### Don't
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0005.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0005

Type: Code Smell

https://agoda-com.github.io/standards-c-sharp/testing/test-method-names-should-clearly-indicate-what-they-are-testing.html

Test method names should clearly communicate what is being tested, under what conditions, and the expected outcome. This makes tests serve as documentation and helps quickly identify what failed when tests break.

Test names should follow this pattern:
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0010.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0010

Type: Code Smell

https://agoda-com.github.io/standards-c-sharp/unit-testing/be-wary-of-refactoring-tests.html

Test fixture inheritance should be avoided as it creates hidden dependencies, makes tests harder to understand, and violates the test isolation principle. Each test class should be independent and self-contained.

#### Don't
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0011.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0011

Type: Code Smell

https://agoda-com.github.io/standards-c-sharp/services/framework-abstractions.html

Direct access to `QueryString` collection bypasses ASP.NET model binding, which provides validation, type conversion, and security features. Always use model binding with action method parameters instead.

#### Don't
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0012.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0012

Type: Bug

https://agoda-com.github.io/standards-c-sharp/testing/tests-as-a-specification.html

Each test method should contain at least one assertion to verify expected behavior. Tests without assertions don't validate anything and provide a false sense of security.

#### Don't
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0013.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ID: AG0013

Type: Code Smell

https://agoda-com.github.io/standards-c-sharp/unit-testing/use-test-cases-appropriately.html

Test methods with too many input parameters become difficult to understand and maintain. When test cases need many parameters, split them into smaller, more focused tests with clear intentions.

#### Don't
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0018.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell

## Summary

https://agoda-com.github.io/standards-c-sharp/collections/choosing-collection-implementation.html

Public methods and properties that return IEnumerable-implementing types must be declared using specific interface types rather than concrete implementations.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0019.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell

## Summary

https://agoda-com.github.io/standards-c-sharp/unit-testing/only-test-the-public-interface.html

The `InternalsVisibleTo` attribute should not be used as it violates encapsulation principles and creates tight coupling between test code and implementation details.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0020.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Bug / Code Smell

## Summary

https://agoda-com.github.io/standards-c-sharp/collections/null-empty-enumerables.html

Methods or properties returning `IEnumerable` types should never return null. Instead, return an empty collection.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0021.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell / Performance

## Summary

https://agoda-com.github.io/standards-c-sharp/async/consume-async-method.html

Always use the asynchronous version of a method when available. Using synchronous methods when async alternatives exist can impact performance and scalability.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0022.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell / API Design

## Summary

https://agoda-com.github.io/standards-c-sharp/async/expose-async-method.html

When designing APIs that perform I/O or CPU-intensive work, expose only the asynchronous version of the method. Never provide both synchronous and asynchronous versions of the same functionality.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0023.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Performance / Code Smell

## Summary

https://agoda-com.github.io/standards-c-sharp/async/avoid-blocking.html

Never use `Thread.Sleep()` for delays in code. Instead, use the asynchronous `Task.Delay()` to avoid blocking threads.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0024.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell / Best Practice

## Summary

https://agoda-com.github.io/standards-c-sharp/async/task-run.html

Avoid using `Task.Factory.StartNew` as it's complex and error-prone. Use `Task.Run` for most scenarios as it provides safer defaults and clearer semantics.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0025.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell / Best Practice

## Summary

https://agoda-com.github.io/standards-c-sharp/async/never-task-continue-with.html

Avoid using `Task.ContinueWith` as it has subtle and non-intuitive behaviors. Use the `await` keyword instead, which is clearer and safer.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0026.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Style / Best Practice

## Summary

https://agoda-com.github.io/standards-c-sharp/gui-testing/css-selectors.html

In Selenium tests, use CSS selectors instead of XPath to locate elements. CSS selectors are more familiar, easier to read, and maintain.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0027.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Best Practice

## Summary

https://agoda-com.github.io/standards-c-sharp/gui-testing/data-selenium.html

Use the `data-selenium` attribute to identify elements in Selenium tests rather than relying on HTML structure, classes, or IDs. This makes tests more resilient to UI changes.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0030.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Bug Risk / Code Smell

## Summary

https://agoda-com.github.io/standards-c-sharp/code-style/dynamics.html

The `dynamic` type should not be used in C# code. It bypasses compile-time type checking and reduces code reliability.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0032.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Bug / Performance

## Summary

https://agoda-com.github.io/standards-c-sharp/async/never-task-wait.html

Avoid using blocking Task methods like `Task.Wait()`, `Task.WaitAll()`, and `Task.WaitAny()`. These methods block threads and can cause deadlocks.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0033.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Bug / Performance

## Summary

https://agoda-com.github.io/standards-c-sharp/async/await-task-result.html

Never use `Task.Result` to get the result of a Task. Use `await` instead. `Task.Result` blocks the current thread and can cause deadlocks.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0035.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell / Architecture

## Summary

https://agoda-com.github.io/standards-c-sharp/configuration/machine-name.html

Avoid using `MachineName` in your code logic. Using machine names creates tight coupling to infrastructure and can lead to environment-specific bugs.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0038.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell

## Summary

https://agoda-com.github.io/standards-c-sharp/code-style/regions.html

The `#region` directive should not be used to organize code. If you feel the need for regions, it's a sign that your code needs refactoring.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0039.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Code Smell

## Summary

https://github.com/agoda-com/AgodaAnalyzers/blob/master/src/Agoda.Analyzers/RuleContent/AG0039MethodLineLengthAnalyzer.html

Methods should be kept reasonably short (recommended max 40 lines excluding whitespace). Long methods should be refactored into smaller, more focused methods while avoiding method chaining.

## Explanation
Expand Down
2 changes: 2 additions & 0 deletions doc/AG0040.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Type: Bug Risk / Test Reliability

## Summary

https://playwright.dev/dotnet/docs/api/class-page#page-go-back

Avoid using `WaitUntilState.NetworkIdle` in Playwright tests as it creates flaky tests. Instead, use explicit web assertions to verify page readiness.

## Explanation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private static readonly LocalizableString Description
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/di/attribute-based-registration.html",
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

protected override IEnumerable<InvocationRule> Rules => new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ private static readonly LocalizableString Description
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: Description
description: Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md"
);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Rule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ private static readonly LocalizableString Description
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/services/framework-abstractions.html",
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class AG0004DoNotUseHardCodedStringsToIdentifyTypes : DiagnosticAnalyzer
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/reflection/hard-coded-strings.html",
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class AG0005TestMethodNamesMustFollowConvention : DiagnosticAnalyzer
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/testing/test-method-names-should-clearly-indicate-what-they-are-testing.html",
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

// Test names must be in the format Xxxx_Yyyy or Xxxx_Yyyy_Zzzz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class AG0006RegisteredComponentShouldHaveExactlyOnePublicConstructor : Di
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
null,
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override void Initialize(AnalysisContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AG0009IHttpContextAccessorCannotBePassedAsMethodArgument : Diagnost

private static readonly DiagnosticDescriptor Descriptor =
new DiagnosticDescriptor(DIAGNOSTIC_ID, Title, MessageFormat, AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, null,
DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, $"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AG0010PreventTestFixtureInheritance : DiagnosticAnalyzer
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/unit-testing/be-wary-of-refactoring-tests.html",
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override void Initialize(AnalysisContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class AG0011NoDirectQueryStringAccess : PropertyInvocationAnalyzerBase
DiagnosticSeverity.Error,
AnalyzerConstants.EnabledByDefault,
DescriptionContentLoader.GetAnalyzerDescription(nameof(AG0011NoDirectQueryStringAccess)),
"https://agoda-com.github.io/standards-c-sharp/services/framework-abstractions.html",
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

protected override IEnumerable<InvocationRule> Rules => new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private static readonly LocalizableString Description
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/testing/tests-as-a-specification.html",
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public AG0013LimitNumberOfTestMethodParametersTo5()
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
DescriptionContentLoader.GetAnalyzerDescription(nameof(AG0013LimitNumberOfTestMethodParametersTo5)),
"https://agoda-com.github.io/standards-c-sharp/unit-testing/use-test-cases-appropriately.html",
DescriptionContentLoader.GetAnalyzerDescription(nameof(AG0013LimitNumberOfTestMethodParametersTo5)),
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private static readonly LocalizableString Description
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/collections/choosing-collection-implementation.html",
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public AG0019PreventUseOfInternalsVisibleToAttribute()
DiagnosticSeverity.Error,
AnalyzerConstants.EnabledByDefault,
DescriptionContentLoader.GetAnalyzerDescription(nameof(AG0019PreventUseOfInternalsVisibleToAttribute)),
"https://agoda-com.github.io/standards-c-sharp/unit-testing/only-test-the-public-interface.html",
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ private static readonly LocalizableString Description
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/collections/null-empty-enumerables.html",
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override void Initialize(AnalysisContext context)
Expand Down
4 changes: 2 additions & 2 deletions src/Agoda.Analyzers/AgodaCustom/AG0021PreferAsyncMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class AG0021PreferAsyncMethods : DiagnosticAnalyzer
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Info,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/async/consume-async-method.html",
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override void Initialize(AnalysisContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class AG0022DoNotExposeBothSyncAndAsyncVersionsOfMethods : DiagnosticAnal
AnalyzerCategory.CustomQualityRules,
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
Description,
"https://agoda-com.github.io/standards-c-sharp/async/expose-async-method.html",
Description,
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(Descriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AG0023PreventUseOfThreadSleep : MethodInvocationAnalyzerBase
DiagnosticSeverity.Warning,
AnalyzerConstants.EnabledByDefault,
nameof(AG0023PreventUseOfThreadSleep),
"https://agoda-com.github.io/standards-c-sharp/async/avoid-blocking.html",
$"https://github.com/agoda-com/AgodaAnalyzers/blob/master/doc/{DIAGNOSTIC_ID}.md",
WellKnownDiagnosticTags.EditAndContinue);


Expand Down
Loading

0 comments on commit 3b73b74

Please sign in to comment.