5cover/Dialogs

View on GitHub
Dialogs/RadioButtonCollection.cs

Summary

Maintainability
A
1 hr
Test Coverage

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)
        {
Severity: Major
Found in Dialogs/RadioButtonCollection.cs and 1 other location - About 1 hr to fix
Dialogs/ButtonCollection.cs on lines 70..79

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

Further Reading

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    /// </remarks>

Incorrect end of line character(s) found.
Open

        _ = base.HandleNotification(notif);

Incorrect end of line character(s) found.
Open

/// <summary>A collection of dialog radio button controls.</summary>

Incorrect end of line character(s) found.
Open

    public RadioButtonCollection(RadioButton defaultItem, IList<RadioButton>? items = null) : base(items, defaultItem)

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    internal override HRESULT HandleNotification(Notification notif)

Incorrect end of line character(s) found.
Open

    public RadioButtonCollection(IList<RadioButton>? items = null) : this(DefaultRadioButton.First, items)

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    /// </value>

Incorrect end of line character(s) found.
Open

    /// <term>Forwards the notification to the clicked button.</term>

Incorrect end of line character(s) found.
Open

        _ = this.ForwardNotification(notif);

Incorrect end of line character(s) found.
Open

    /// <param name="defaultItemStrategy">The default radio button strategy.</param>

Incorrect end of line character(s) found.
Open

public sealed class RadioButtonCollection : IdControlCollection<RadioButton>

Incorrect end of line character(s) found.
Open

        => _defaultItemStrategy = defaultItemStrategy;

Incorrect end of line character(s) found.
Open

    /// <value>

Incorrect end of line character(s) found.
Open

    /// <param name="text">The label.</param>

Incorrect end of line character(s) found.
Open

    /// </item>

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    /// selected.

Incorrect end of line character(s) found.
Open

    protected override void SetConfigProperties(in TASKDIALOGCONFIG config, nint nativeButtonArrayHandle, uint nativeButtonArrayCount, int defaultItemId)

Incorrect end of line character(s) found.
Open

/// <inheritdoc path="//remarks"/>

Incorrect end of line character(s) found.
Open

    /// <term><see cref="RadioButton.HandleNotification(Notification)"/></term>

Incorrect end of line character(s) found.
Open

namespace Scover.Dialogs;

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

{

Incorrect end of line character(s) found.
Open

    /// The currently selected radio button, or <see langword="null"/> if no radio button is currently

Incorrect end of line character(s) found.
Open

    public RadioButton? Selected { get; }

Incorrect end of line character(s) found.
Open

    protected override TASKDIALOG_FLAGS Flags => _defaultItemStrategy?.Flags ?? 0;

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

        }

Incorrect end of line character(s) found.
Open

    /// <summary>Adds a new radio button to the collection.</summary>

Incorrect end of line character(s) found.
Open

        if (notif.Id is TDN_RADIO_BUTTON_CLICKED)

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    }

Incorrect end of line character(s) found.
Open

    /// <list type="table">

Incorrect end of line character(s) found.
Open

    /// <term>Anything else</term>

Incorrect end of line character(s) found.
Open

    /// <inheritdoc/>

Incorrect end of line character(s) found.
Open

    /// <param name="items">The initial items to add to the collection.</param>

Incorrect end of line character(s) found.
Open

    {

Incorrect end of line character(s) found.
Open

    /// <summary>Gets a reference to the currently selected radio button.</summary>

Incorrect end of line character(s) found.
Open

            return GetItem((int)notif.WParam) is { } radioButton ? radioButton.HandleNotification(notif) : default;

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    /// <term>Forwards the notification to all items.</term>

Incorrect end of line character(s) found.
Open

    {

Incorrect end of line character(s) found.
Open

        => (config.pRadioButtons, config.cRadioButtons, config.nDefaultRadioButton) = (nativeButtonArrayHandle, nativeButtonArrayCount, defaultItemId);

Incorrect end of line character(s) found.
Open

using Vanara.PInvoke;

Incorrect end of line character(s) found.
Open

    public void Add(string text) => Add(new RadioButton(text));

Incorrect end of line character(s) found.
Open

    /// <remarks>

Incorrect end of line character(s) found.
Open

    /// </item>

Incorrect end of line character(s) found.
Open

    /// </list>

Incorrect end of line character(s) found.
Open

    }

Incorrect end of line character(s) found.
Open

    /// <inheritdoc/>

Incorrect end of line character(s) found.
Open

    /// <param name="items">The initial items to add to the collection.</param>

Incorrect end of line character(s) found.
Open

        => Selected = defaultItem;

Incorrect end of line character(s) found.
Open

    /// <inheritdoc path="//remarks//listheader"/><inheritdoc path="//remarks//item"/>

Incorrect end of line character(s) found.
Open

    /// <item>

Incorrect end of line character(s) found.
Open

using static Vanara.PInvoke.ComCtl32;

Incorrect end of line character(s) found.
Open

    public RadioButtonCollection(DefaultRadioButton defaultItemStrategy, IList<RadioButton>? items = null) : base(items, null)

Incorrect end of line character(s) found.
Open

    /// <param name="defaultItem">The default radio button.</param>

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    /// <item>

Incorrect end of line character(s) found.
Open

    /// <term><see cref="TDN_RADIO_BUTTON_CLICKED"/></term>

Incorrect end of line character(s) found.
Open

        return default;

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    private readonly DefaultRadioButton? _defaultItemStrategy;

Incorrect end of line character(s) found.
Open

    /// <param name="items">The initial items to add to the collection.</param>

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    /// <inheritdoc/>

Incorrect end of line character(s) found.
Open

        {

There are no issues that match your filters.

Category
Status