Close

Bloat Code Tracker

A project log for Source Code Analysis: PowerShellEditorServices

Source Code Breakdown of PowerShellEditorServices (at the time of v3.5.4)

nicholas-jacksonNicholas Jackson 10/31/2022 at 23:040 Comments

This repository is ridiculously bloated

This log will be used to track all known instances of bloatcode in the repo

Unneccessary profilepath processor code

The code that follows this line can be reduced to this:

PSMemberInfoCollection<PSPropertyInfo> profiles = profile.Properties
ProfilePaths = new ProfilePathConfig
{
  AllUsersAllHosts = (string)profiles.AllUsersAllHosts.Value,
  AllUsersCurrentHost = Path.Combine(
    Path.GetDirectoryName( (string)profiles.AllUsersCurrentHost.Value ),
    $"{HostProfileId}_profile.ps1" ),
  CurrentUserAllHosts = (string)profiles.CurrentUserAllHosts.Value,
  CurrentUserCurrentHost = Path.Combine(
    Path.GetDirectoryName( (string)profiles.CurrentUserCurrentHost.Value ),
    $"{HostProfileId}_profile.ps1" ),
},

 All referenced Enums and Methods for this generation can then be deleted

Unused EditorServicesLoader.Create() signature

According to this search, this signature never gets used.

Literally any instance of Object.Create()

We don't need to reinvent the "new" keyword. Named constructors should only be used where verbose names make the constructor look like more than just a constructor. For example Int32.Parse() is a good named constructor; Int32.Create() is not

ModulePath Modifying functions could probably be merged

EditorServicesLoader.UpdatePSModulePath() should probably include the code from the CreateConfigObject method on the cmdlet

Usages of PowerShell translated to C#, instead of just using C#

instead of using System.Text.Json to serialize to Json, they use the PowerShell command ConvertTo-Json to do it instead, but from C#. This is one of the most hilarious instances of bloat code I have ever seen

ProfilePaths is literally reinvinted just to be used as a parameter. No additions, just cloned into a new object.

This code doesn't need to be here.

Modifications to the BundledModulesPath variable

this doesn't need to be done in 5 different spots across the utility. Jesus Christ

Discussions