question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I avoid having to set the severity and name for each rule?

See original GitHub issue

When I have the following, is there any way I can avoid having to set the severity and name for each rule?

            RuleFor(envelope => envelope.Body.MOARequest.Header.RequestID.Text)
                .NotNull()
                .WithSeverity(Severity.Warning)
                .WithName(NameOf(envelope => envelope.Body.MOARequest.Header.RequestID))
                .NotEmpty()
                .WithSeverity(Severity.Warning)
                .WithName(NameOf(envelope => envelope.Body.MOARequest.Header.RequestID))
                .MaximumLength(20)
                .WithSeverity(Severity.Warning)
                .WithName(NameOf(envelope => envelope.Body.MOARequest.Header.RequestID))
                .When(envelope => envelope?.Body?.MOARequest?.Header?.RequestID != null);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Jan 22, 2021

Could that be added to the docs

Sure, feel free to send a pull request to add this in, otherwise I’ll try and get to it when I have a bit of time

0reactions
JeremySkinnercommented, Jan 22, 2021

Unless mistaken, that won’t work with expressions though will it as I can’t get the expression body.

The third parameter of the global display name resolver is the expression, so yes you can get the expression body.

Edit: sorry I misunderstood, I thought you meant the expression for which the rule was defined

Read more comments on GitHub >

github_iconTop Results From Across the Web

All rules have default "error" severity · Issue #23 · stylelint ...
In this case, the syntax for setting the severity for each individual rule makes the configuration really verbose and hard to maintain, so ......
Read more >
Defining rule severity - TechDocs - Broadcom Inc.
To define a policy rule severity · Configure a policy rule. · Select a · Click · Select the desired severity level, choose...
Read more >
Code analysis rule categories - .NET
NET design guidelines, and security rules help prevent security flaws. You can configure the severity level for an entire category of rules.
Read more >
Managing Severity Rules
1. In the Configuration view, select Events > Security Events Log > Security Log. 2. Click the Severity Rules tab. A list of...
Read more >
Analyzer configuration - Visual Studio (Windows)
Right-click the rule and select Set severity. In the context menu, choose one of the severity options. Visual Studio adds an entry to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found