Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TE - sf code analyzer, only changed files #53

Open
mvogelgesang opened this issue Aug 31, 2023 · 0 comments
Open

TE - sf code analyzer, only changed files #53

mvogelgesang opened this issue Aug 31, 2023 · 0 comments

Comments

@mvogelgesang
Copy link
Owner

mvogelgesang commented Aug 31, 2023

Quick write up about using Salesforce code analyzer to scan only the files changed in a given commit

// lint-staged.config.js
module.exports = {
  "**/*.cls": (filenames) => `sf scanner run -f table -s 3 -t ${filenames.join(", ")}`
};
// package.json
{
"lint-staged": {
    "**/*.{cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}": [
      "prettier --write"
    ],
    "**/{aura,lwc}/**": [
      "eslint"
    ],
    "**/*.cls" : [
      "prettier --write"
    ]
  }
}
// ContactHelper.cls
public with sharing class ContactHelper {
  public ContactHelper() {
  }
  public static doY() {
    // if (!Schema.sObjectType.Opportunity.fields.Amount.isCreateable()){
    //    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,
    //    'Error: Insufficient Access'));
    //    return null;
    // }
    Contact c = new Contact();
    // specify other fields
    c.Title = 'Poo Bah';
    database.insert(c);
  }
}
<!-- ContactHelper.cls-meta.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>58.0</apiVersion>
    <status>Active</status>
</ApexClass>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant