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.
The following attribute class can be found in several code files. CodeFactor found this as duplicated code and grades this as a severe issue.
found in
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.