Similar blocks of code found in 2 locations. Consider refactoring. Open
internal override HRESULT HandleNotification(Notification notif)
{
_ = base.HandleNotification(notif);
if (notif.Id is TDN_RADIO_BUTTON_CLICKED)
{
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 99.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
/// </remarks>
- Exclude checks
Incorrect end of line character(s) found. Open
_ = base.HandleNotification(notif);
- Exclude checks
Incorrect end of line character(s) found. Open
/// <summary>A collection of dialog radio button controls.</summary>
- Exclude checks
Incorrect end of line character(s) found. Open
public RadioButtonCollection(RadioButton defaultItem, IList<RadioButton>? items = null) : base(items, defaultItem)
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
internal override HRESULT HandleNotification(Notification notif)
- Exclude checks
Incorrect end of line character(s) found. Open
public RadioButtonCollection(IList<RadioButton>? items = null) : this(DefaultRadioButton.First, items)
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
/// </value>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <term>Forwards the notification to the clicked button.</term>
- Exclude checks
Incorrect end of line character(s) found. Open
_ = this.ForwardNotification(notif);
- Exclude checks
Incorrect end of line character(s) found. Open
/// <param name="defaultItemStrategy">The default radio button strategy.</param>
- Exclude checks
Incorrect end of line character(s) found. Open
public sealed class RadioButtonCollection : IdControlCollection<RadioButton>
- Exclude checks
Incorrect end of line character(s) found. Open
=> _defaultItemStrategy = defaultItemStrategy;
- Exclude checks
Incorrect end of line character(s) found. Open
/// <value>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <param name="text">The label.</param>
- Exclude checks
Incorrect end of line character(s) found. Open
/// </item>
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
/// selected.
- Exclude checks
Incorrect end of line character(s) found. Open
protected override void SetConfigProperties(in TASKDIALOGCONFIG config, nint nativeButtonArrayHandle, uint nativeButtonArrayCount, int defaultItemId)
- Exclude checks
Incorrect end of line character(s) found. Open
/// <inheritdoc path="//remarks"/>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <term><see cref="RadioButton.HandleNotification(Notification)"/></term>
- Exclude checks
Incorrect end of line character(s) found. Open
namespace Scover.Dialogs;
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
{
- Exclude checks
Incorrect end of line character(s) found. Open
/// The currently selected radio button, or <see langword="null"/> if no radio button is currently
- Exclude checks
Incorrect end of line character(s) found. Open
public RadioButton? Selected { get; }
- Exclude checks
Incorrect end of line character(s) found. Open
protected override TASKDIALOG_FLAGS Flags => _defaultItemStrategy?.Flags ?? 0;
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
}
- Exclude checks
Incorrect end of line character(s) found. Open
/// <summary>Adds a new radio button to the collection.</summary>
- Exclude checks
Incorrect end of line character(s) found. Open
if (notif.Id is TDN_RADIO_BUTTON_CLICKED)
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
}
- Exclude checks
Incorrect end of line character(s) found. Open
/// <list type="table">
- Exclude checks
Incorrect end of line character(s) found. Open
/// <term>Anything else</term>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <inheritdoc/>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <param name="items">The initial items to add to the collection.</param>
- Exclude checks
Incorrect end of line character(s) found. Open
{
- Exclude checks
Incorrect end of line character(s) found. Open
/// <summary>Gets a reference to the currently selected radio button.</summary>
- Exclude checks
Incorrect end of line character(s) found. Open
return GetItem((int)notif.WParam) is { } radioButton ? radioButton.HandleNotification(notif) : default;
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
/// <term>Forwards the notification to all items.</term>
- Exclude checks
Incorrect end of line character(s) found. Open
{
- Exclude checks
Incorrect end of line character(s) found. Open
=> (config.pRadioButtons, config.cRadioButtons, config.nDefaultRadioButton) = (nativeButtonArrayHandle, nativeButtonArrayCount, defaultItemId);
- Exclude checks
Incorrect end of line character(s) found. Open
using Vanara.PInvoke;
- Exclude checks
Incorrect end of line character(s) found. Open
public void Add(string text) => Add(new RadioButton(text));
- Exclude checks
Incorrect end of line character(s) found. Open
/// <remarks>
- Exclude checks
Incorrect end of line character(s) found. Open
/// </item>
- Exclude checks
Incorrect end of line character(s) found. Open
/// </list>
- Exclude checks
Incorrect end of line character(s) found. Open
}
- Exclude checks
Incorrect end of line character(s) found. Open
/// <inheritdoc/>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <param name="items">The initial items to add to the collection.</param>
- Exclude checks
Incorrect end of line character(s) found. Open
=> Selected = defaultItem;
- Exclude checks
Incorrect end of line character(s) found. Open
/// <inheritdoc path="//remarks//listheader"/><inheritdoc path="//remarks//item"/>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <item>
- Exclude checks
Incorrect end of line character(s) found. Open
using static Vanara.PInvoke.ComCtl32;
- Exclude checks
Incorrect end of line character(s) found. Open
public RadioButtonCollection(DefaultRadioButton defaultItemStrategy, IList<RadioButton>? items = null) : base(items, null)
- Exclude checks
Incorrect end of line character(s) found. Open
/// <param name="defaultItem">The default radio button.</param>
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
/// <item>
- Exclude checks
Incorrect end of line character(s) found. Open
/// <term><see cref="TDN_RADIO_BUTTON_CLICKED"/></term>
- Exclude checks
Incorrect end of line character(s) found. Open
return default;
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
private readonly DefaultRadioButton? _defaultItemStrategy;
- Exclude checks
Incorrect end of line character(s) found. Open
/// <param name="items">The initial items to add to the collection.</param>
- Exclude checks
Incorrect end of line character(s) found. Open
- Exclude checks
Incorrect end of line character(s) found. Open
/// <inheritdoc/>
- Exclude checks
Incorrect end of line character(s) found. Open
{
- Exclude checks