Skip to content

CodeFactor: Duplicated code for argument completions attribute class #7724

Closed

Description

@ThreeFive-O

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.

Activity

  1. added
    Issue-Enhancementthe issue is more of a feature request than a bug
    WG-Enginecore PowerShell engine, interpreter, and runtime
    on Sep 7, 2018
  2. iSazonov commented on Sep 7, 2018

    @iSazonov
    Collaborator

    ThreeFive-O Feel free to offer PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions