Skip to content

Commit

Permalink
Salesforce use sf + default Flow Scanner rules (#3435)
Browse files Browse the repository at this point in the history
* Salesforce use sf + default Flow Scanner rules

* More use sf

* Add second error file for Flows tests

---------

Co-authored-by: nvuillam <[email protected]>
  • Loading branch information
nvuillam and nvuillam authored Mar 16, 2024
1 parent c23784a commit c786477
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<description>This flow demonstrates a violation of the rule &quot;Unused Variable&quot;.</description>
<environments>Default</environments>
<interviewLabel>Unused Variable {!$Flow.CurrentDateTime}</interviewLabel>
<label>Unused Variable</label>
<processMetadataValues>
<name>BuilderType</name>
<value>
<stringValue>LightningFlowBuilder</stringValue>
</value>
</processMetadataValues>
<processMetadataValues>
<name>CanvasMode</name>
<value>
<stringValue>AUTO_LAYOUT_CANVAS</stringValue>
</value>
</processMetadataValues>
<processMetadataValues>
<name>OriginBuilderType</name>
<value>
<stringValue>LightningFlowBuilder</stringValue>
</value>
</processMetadataValues>
<processType>Flow</processType>
<screens>
<name>mock_screen</name>
<label>mock screen</label>
<locationX>176</locationX>
<locationY>134</locationY>
<allowBack>true</allowBack>
<allowFinish>true</allowFinish>
<allowPause>true</allowPause>
<showFooter>true</showFooter>
<showHeader>true</showHeader>
</screens>
<start>
<locationX>50</locationX>
<locationY>0</locationY>
<connector>
<targetReference>mock_screen</targetReference>
</connector>
</start>
<status>Active</status>
<variables>
<name>anUnusedVariable</name>
<dataType>String</dataType>
<isCollection>false</isCollection>
<isInput>false</isInput>
<isOutput>false</isOutput>
<value>
<stringValue>hello world</stringValue>
</value>
</variables>
</Flow>
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Fixes
- Fix conflict between prettier and yamllint about spaces
- Ensure [trufflehog](https://github.com/trufflesecurity/trufflehog) does not auto-update itself
- Salesforce linters: use sf + default Flow Scanner rules

- Doc

Expand Down
41 changes: 41 additions & 0 deletions TEMPLATES/.flow-scanner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"rules": {
"APIVersion": {
"severity": "warning"
},
"CopyAPIName": {
"severity": "warning"
},
"DMLStatementInLoop": {
"severity": "error"
},
"DuplicateDMLOperation": {
"severity": "error"
},
"FlowDescription": {
"severity": "note"
},
"FlowName": {
"severity": "warning",
"expression": "[A-Za-z0-9]+_(SCR|SFL|SCH|EVT|EML|BeforeCreate|BeforeUpdate|BeforeDelete|BeforeCreateBeforeUpdate|AfterCreate|AfterUpdate|AfterDelete|AfterCreateAfterUpdate)_[A-Za-z0-9]+"
},
"HardcodedId": {
"severity": "error"
},
"MissingFaultPath": {
"severity": "note"
},
"MissingNullHandler": {
"severity": "note"
},
"SOQLQueryInLoop": {
"severity": "error"
},
"UnconnectedElement": {
"severity": "error"
},
"UnusedVariable": {
"severity": "error"
}
}
}
34 changes: 17 additions & 17 deletions megalinter/descriptors/salesforce.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
- ENV PATH="$JAVA_HOME/bin:${PATH}"
- |
RUN sf plugins install @salesforce/plugin-packaging \
&& echo y|sfdx plugins:install sfdx-hardis \
&& echo y|sf plugins install sfdx-hardis \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache
# Salesforce DX
Expand Down Expand Up @@ -41,7 +41,7 @@ linters:
linter_rules_inline_disable_url: https://docs.pmd-code.org/latest/pmd_userdocs_suppressing_warnings.html
linter_megalinter_ref_url: https://github.com/forcedotcom/sfdx-scanner/pull/307
config_file_name: apex-pmd-ruleset.xml
cli_executable: sfdx
cli_executable: sf
cli_config_arg_name: "--pmdconfig"
cli_lint_extra_args:
- "scanner:run"
Expand All @@ -59,19 +59,19 @@ linters:
cli_help_extra_args:
- "scanner:run"
cli_help_extra_commands:
- "sfdx scanner:rule:list"
- "sf scanner:rule:list"
cli_version_extra_args:
- "plugins"
cli_version_arg_name: ""
version_extract_regex: "(?<=@salesforce/sfdx-scanner )\\d+(\\.\\d+)+"
cli_lint_errors_count: regex_sum
cli_lint_errors_regex: "found ([0-9]+) violation"
examples:
- "sfdx scanner:run"
- "sf scanner:run"
install:
dockerfile:
- |
RUN sfdx plugins:install @salesforce/sfdx-scanner \
RUN sf plugins install @salesforce/sfdx-scanner \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache
ide:
Expand Down Expand Up @@ -112,7 +112,7 @@ linters:
linter_megalinter_ref_url: https://github.com/forcedotcom/sfdx-scanner/pull/307
config_file_name: --eslintconfig
cli_config_arg_name: ".eslintrc-aura.json"
cli_executable: sfdx
cli_executable: sf
cli_lint_extra_args:
- "scanner:run"
- "--engine"
Expand All @@ -129,19 +129,19 @@ linters:
cli_help_extra_args:
- "scanner:run"
cli_help_extra_commands:
- "sfdx scanner:rule:list"
- "sf scanner:rule:list"
cli_version_extra_args:
- "plugins"
cli_version_arg_name: ""
version_extract_regex: "(?<=@salesforce/sfdx-scanner )\\d+(\\.\\d+)+"
cli_lint_errors_count: regex_sum
cli_lint_errors_regex: "found ([0-9]+) violation"
examples:
- "sfdx scanner:run"
- "sf scanner:run"
install:
dockerfile:
- |
RUN sfdx plugins:install @salesforce/sfdx-scanner \
RUN sf plugins install @salesforce/sfdx-scanner \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache
ide:
Expand Down Expand Up @@ -172,7 +172,7 @@ linters:
linter_megalinter_ref_url: https://github.com/forcedotcom/sfdx-scanner/pull/307
config_file_name: --eslintconfig
cli_config_arg_name: ".eslintrc-lwc.json"
cli_executable: sfdx
cli_executable: sf
cli_lint_extra_args:
- "scanner:run"
- "--engine"
Expand All @@ -189,19 +189,19 @@ linters:
cli_help_extra_args:
- "scanner:run"
cli_help_extra_commands:
- "sfdx scanner:rule:list"
- "sf scanner:rule:list"
cli_version_extra_args:
- "plugins"
cli_version_arg_name: ""
version_extract_regex: "(?<=@salesforce/sfdx-scanner )\\d+(\\.\\d+)+"
cli_lint_errors_count: regex_sum
cli_lint_errors_regex: "found ([0-9]+) violation"
examples:
- "sfdx scanner:run"
- "sf scanner:run"
install:
dockerfile:
- |
RUN sfdx plugins:install @salesforce/sfdx-scanner \
RUN sf plugins install @salesforce/sfdx-scanner \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache
ide:
Expand All @@ -223,7 +223,7 @@ linters:
linter_rules_configuration_url: https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-sfdx#configuration
config_file_name: .flow-scanner.json
cli_config_arg_name: --config
cli_executable: sfdx
cli_executable: sf
cli_lint_extra_args:
- "flow:scan"
cli_lint_mode: project
Expand All @@ -234,14 +234,14 @@ linters:
cli_version_arg_name: ""
version_extract_regex: "(?<=lightning-flow-scanner )\\d+(\\.\\d+)+"
cli_lint_errors_count: regex_number
cli_lint_errors_regex: "=== Total: ([0-9]+) Results in .* Flows"
cli_lint_errors_regex: "- error: ([0-9]+)"
test_folder: salesforce-lfs
examples:
- "sfdx flow:scan"
- "sf flow:scan"
install:
dockerfile:
- |
RUN echo y|sfdx plugins:install lightning-flow-scanner \
RUN echo y|sf plugins install lightning-flow-scanner \
&& npm cache clean --force || true \
&& rm -rf /root/.npm/_cacache
ide:
Expand Down

0 comments on commit c786477

Please sign in to comment.