Skip to content

Instantly share code, notes, and snippets.

View rahulmalhotra's full-sized avatar
😃
Working on something amazing...!!

Rahul Malhotra rahulmalhotra

😃
Working on something amazing...!!
View GitHub Profile
@rahulmalhotra
rahulmalhotra / pmd
Last active December 16, 2017 16:58
pmd command syntax
pmd -d <filename or dir with path> -f <output format> -R <default rule or rule file with path> -reportfile <output file name with path>
@rahulmalhotra
rahulmalhotra / myrules.xml
Last active December 17, 2017 06:09
Ruleset file with custom rules for pmd
<?xml version="1.0"?>
<ruleset name="Custom Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
My Custom rules
</description>
<!-- Using a single rule from a set of predefined rules -->
<rule ref="category/apex/bestpractices.xml/AvoidLogicInTrigger" />
cpd --minimum-tokens <minimum token value that must be duplicated> --files <path to single file or directory> --language <name of language in which code is written>
@rahulmalhotra
rahulmalhotra / test.cls
Created December 17, 2017 05:19
Code snippet throwing error because of excessive parameters
public void doMoreWork(Integer p1, Integer p1, Integer p3, Integer p4 ) {
System.log('function with excessive parameters');
}
@rahulmalhotra
rahulmalhotra / cpdsample.cls
Created December 17, 2017 05:27
Sample cpd command to find duplicate code
cpd.bat --minimum-tokens 5 --files "C:\Users\Rahul Malhotra\Documents\My Lightning Org\src\classes\test.cls" --language apex
@rahulmalhotra
rahulmalhotra / Lightning Init Handler.js
Created March 25, 2018 10:41
Init handler sample code used in events introduction blog - Sfdcstop
<aura:handler name="init" action="{!c.getContactsList}" value="{!this}" />
@rahulmalhotra
rahulmalhotra / LightningEventsComp1Controller.js
Created April 5, 2018 09:02
Event handler at source component used in Salesforce Lightning Events Tutorial Repository - SFDCStop
// Function to handle Lightning Event fired from this component itself.
handleRegisteredComponentEvent: function(component, event, helper) {
alert('Event handler at source component that fired the event.');
event.stopPropagation();
},
@rahulmalhotra
rahulmalhotra / LightningEventsComp1.cmp
Last active April 6, 2018 06:51
Component file used in Salesforce Lightning Events Tutorial - SFDC Stop Part 3 showing only the handler.
<aura:handler name="totalIncomeComponentEvent" event="c:LightningComponentEvent" action="{!c.handleRegisteredComponentEvent}" phase="capture"></aura:handler>
@rahulmalhotra
rahulmalhotra / LightningEventsCompContainer.cmp
Created April 6, 2018 07:03
Updated Handler in Lightning Events Container File used in Salesforce Lightning Events Tutorial Part 3 - SFDC Stop Blog
<aura:handler name="totalIncomeComponentEvent" event="c:LightningComponentEvent" action="{!c.handleTotalIncomeComponentEvent}" phase="capture"></aura:handler>
@rahulmalhotra
rahulmalhotra / LightningEventsCompContainerController.js
Last active April 6, 2018 07:42
Controller file in container component used in Lightning Events Tutorial Part 3 by SFDC Stop - added event.stopPropagation();
({
// Function to handle Lightning Event
handleTotalIncomeComponentEvent : function(component, event, helper) {
alert('Event handler at the parent component');
// Getting the value of totalIncome attribute of event using event.getParam()
var totalIncome = event.getParam('totalIncome');
// Setting the totalIncome attribute of component with the event's totalIncome attribute value.
component.set('v.totalIncome', totalIncome);
event.stopPropagation();
}