hardisgroupcom / sfdx-hardis

Swiss-army-knife Toolbox for Salesforce. Orchestrates base commands and assist users with interactive wizards to make much more than native sfdx + Allows you to define a complete CI/CD Pipeline and Schedule a daily Metadata backup & monitoring of your orgs
https://sfdx-hardis.cloudity.com
GNU Affero General Public License v3.0
194 stars 35 forks source link

New linter for checking if referenced metadata is in repository #348

Open przemekrcloudity opened 1 year ago

przemekrcloudity commented 1 year ago

General Idea

Detect references to metadata (for example in profiles, permission sets, permission set groups...) that no longer exist

Motivation

It's very easy to remove metadata that is no longer used but forget to remove all references to it in other files. While using partial deployments based on git-diff, this will not be detected by SF as file with references to removed metadata was not deployed. An example from my last month would be removing the field of SObject but not removing it from profiles and permission sets.

What is worse is that SFDX will inform user only about first occurrence of metadata that doesn't exist and with each next deployment user will learn about new metadata that is not included in repository. This can significantly increase build-fixing time

Propsoal

Add command to lint folder that would scan project for known metadata types (apex classes, fields, labels) and then check

for references to these fields.

Possible problems

I believe that references to components from namespaces should be skipped during analisis

nvuillam commented 1 year ago

That would be GREAT 👓

And even greater (maybe in a second version), a --fix option ? :D