Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

CodeFactor: Duplicated code for argument completions attribute class #7724

Copy link
Copy link
@ThreeFive-O

Description

@ThreeFive-O
Issue body actions

The following attribute class can be found in several code files. CodeFactor found this as duplicated code and grades this as a severe issue.

[ArgumentCompletions(
            EncodingConversion.Ascii,
            EncodingConversion.BigEndianUnicode,
            EncodingConversion.OEM,
            EncodingConversion.Unicode,
            EncodingConversion.Utf7,
            EncodingConversion.Utf8,
            EncodingConversion.Utf8Bom,
            EncodingConversion.Utf8NoBom,
            EncodingConversion.Utf32
            )]

found in

src\Microsoft.PowerShell.Commands.Utility\commands\utility\Send-MailMessage.cs:63-73 
src\Microsoft.PowerShell.Commands.Utility\commands\utility\CSVCommands.cs:210-220 
src\Microsoft.PowerShell.Commands.Utility\commands\utility\CSVCommands.cs:594-604 
src\Microsoft.PowerShell.Commands.Utility\commands\utility\ImplicitRemotingCommands.cs:80-90 
src\Microsoft.PowerShell.Commands.Utility\commands\utility\MatchString.cs:1198-1208 
src\Microsoft.PowerShell.Commands.Utility\commands\utility\XmlCommands.cs:110-120 
src\System.Management.Automation\namespaces\FileSystemProvider.cs:7215-7225 
src\Microsoft.PowerShell.Commands.Utility\commands\utility\FormatAndOutput\format-hex\Format-Hex.cs:53-63 
src\Microsoft.PowerShell.Commands.Utility\commands\utility\FormatAndOutput\out-file\Out-File.cs:75-85

The CodeFactor grading could improve for each of the mentioned code files if the attribute class would be replaced by a single attribute class dedicated for the Encoding Conversion argument completion.
e.g.

[ArgumentEncodingConversionCompletions]

in lieu of the above. This would be similar to the [ArgumentToEncodingTransformationAttribute] which consolidates the function to transform the properties from a string to the correct encoding enum.

Furthermore a centrally defined attribute for the Encoding completion would prevent mistakes if another encoding is added in the future.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.