forcekit
v1.2.11
Published
A code review CLI that lets you scan your code for Apex, Visualforce and Lightning specific issues.
Downloads
6
Maintainers
Readme
forcekit CLI
Introduction
Sometimes it happens that due to lack of time or knowledge or in pressure we forget to follow the specified code quality standards which somehow impact the overall quality of the product. To measures the quality standards we are only left with the manually process of reviewing the code line by line which is time consuming as well as not that much reliable.
So to figure out this issues I have come up with a tool named forcekit CLI, which is a code review tool that lets you scan your code for Apex, Visualforce and Lightning specific issues. It helps in identifying those loop holes (dirty code) which impact the overall quality of the product i.e. Its helps you to know where there is a need to improve your code to match the standard quality.
It’s a completely automated tool which will help you to enhance the quality of the code as well as of the product.
Installation
install the forcekit CLI using the following command:
npm install -g forcekit
This CLI tool uses the following major external libraries:
- jsforce - JSforce (f.k.a. Node-Salesforce) is an isomorphic JavaScript Library utilizing Salesforce's API: It works both in the browser and with Node.js. more details
- eslint - ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.more details
- PMD - PMD scans source code in Java and other languages and looks for potential problems.more details
Usage
After installation the forcekit CLI tool will be available to you. It is the entrypoint for all the functionality mentioned above.
You can call forcekit <command> --help
to find out more about all of the following commands.
Available Commands
User Commands
forcekit login - Log in to your salesforce account.
Options :
--username The username to log in with. --password The password to use when logging in. -sandbox Log in to sandbox org.
forcekit whoami - Know current logged in user information.
forcekit logout - Log out of your current session.
Deployment Commands
forcekit retrieve - Retrieve resource from org.
Options :
-D, --directory [directory] Directory path to extract the retrieved metadata files. Should be a list (comma-separated) if there are multiple entries in packageNames -Z, --zipFile [zipFile] Output file path of ZIP archive of retrieved metadata. -P, --packageXML [packageXML] A package.xml file path to specify the retrieving metadata contents. --pid [pid] Process ID of previous retrieve request. --apiVersion [apiVersion] API version of retrieving package. -P, --packageNames [packageNames] List of package names to retrieve (comma separated). -M, --memberTypes [memberTypes] Metadata types and its members. The format is like following: "[ApexClass:Class1,Class2],[ApexPage:Page1,Page2],[ApexTrigger:*]" --pollTimeout [pollTimeout] Polling timeout in millisec (default is 60000ms). --pollInterval [pollInterval] Polling interval in millisec (default is 5000ms). -v, --verbose Output execution detail log.
forcekit deploy - Deploy resource to another org.
Options :
-U, --username [username] Target org user name. -P, --password [password] Target org password. -D, --directory [directory] Local directory path of the package to deploy. -Z, --zipFile [zipFile] Input file path of ZIP archive of metadata files to deploy. --pid [pid] Process ID of previous deployment to check status. --dryRun Dry run. Same as --checkOnly. -RT, --testLevel [testLevel] Specifies which tests are run as part of a deployment (NoTestRun/RunSpecifiedTests/RunLocalTests/RunAllTestsInOrg). -RT, --runTests [runTests] A list of Apex tests to run during deployment (commma separated). -IW, --ignoreWarnings Indicates whether a warning should allow a deployment to complete successfully (true) or not (false). -RB, --rollbackOnError Indicates whether any failure causes a complete rollback (true) or not (false). --pollTimeout [pollTimeout] Polling timeout in millisec (default is 60000ms). --pollInterval [pollInterval] Polling interval in millisec (default is 5000ms). -v, --verbose Output execution detail log.
Code Review Commands
forcekit review - Review source code.
Options :
-T, --type [type] VF/APEX/LC. -D, --directory [directory] Local directory path of the package. -L, --list Show all of the rules available. -R, --rule Comma separated list of rule names to use.
Review Rules
Visualforce
- alt-require : The alt attribute of an
<img>
element must be present and alt attribute of area[href] and input[type=image] must have a value. - attr-lowercase : All attribute names must be in lowercase.
- attr-no-duplication : Elements cannot have duplicate attributes.
- attr-unsafe-chars : Attribute values cannot contain unsafe chars.
- attr-value-double-quotes : Attribute values must be in double quotes.
- attr-value-not-empty : All attributes must have values.
- csslint : Scan css with csslint.
- form-count : Minimize number of forms on a page.
- head-script-disabled : The
<script>
tag cannot be used in a<head>
tag. - href-abs-or-rel : An href attribute must be either absolute or relative.
- html-disabled : Do not use the
<HTML>
tag. - id-class-ad-disabled : The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.
- id-class-value : The id and class attribute values must meet the specified rules.
- id-unique : The value of id attributes must be unique.
- inline-script-disabled : Inline script cannot be used.
- inline-style-disabled : Inline style cannot be used.
- jshint : Scan script with jshint.
- space-tab-mixed-disabled : Do not mix tabs and spaces for indentation.
- spec-char-escape : Special characters must be escaped.
- src-not-empty : The src attribute of an img(script,link) must have a value.
- style-disabled :
<style>
tags cannot be used. - tag-pair : Tag must be paired.
- tag-self-close : Empty tags must be self closed.
- tagname-lowercase : All html element names must meet the camelCase style.
Apex
- security : These rules deal with different security problems that can occur within Apex. (default)
- apexunit : These rules deal with different problems that can occur with Apex unit tests. (default)
- complexity : The Complexity ruleset contains rules that find problems related to code size or complexity. (default)
- performance : The Performance ruleset contains a collection of good practices which should be followed. (default)
- style : The Style Ruleset contains rules regarding preferred usage of names and identifiers. (default)
Lightning JS
- eqeqeq : This rule is aimed at eliminating the type-unsafe equality operators.
- no-eq-null : The rule aims reduce potential bug and unwanted behavior by ensuring that comparisons to null only match null, and not also undefined.
- no-console : This rule disallows calls to methods of the console object.
- no-alert : This rule is aimed at catching debugging code that should be removed and popup UI elements that should be replaced with less obtrusive, custom UIs.
- no-unused-vars : This rule is aimed at eliminating unused variables, functions, and parameters of functions.
- no-undef : Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /global .../ comment.
- no-mixed-spaces-and-tabs : This rule disallows mixed spaces and tabs for indentation.
- block-scoped-var : This rule aims to reduce the usage of variables outside of their binding context and emulate traditional block scope from other languages.
- consistent-return : Require return statements to either always or never specify values (consistent-return).
- curly : This rule is aimed at preventing bugs and increasing code clarity by ensuring that block statements are wrapped in curly braces.
- guard-for-in : This rule is aimed at preventing unexpected behavior that could arise from using a for in loop without filtering the results in the loop.
- no-plusplus : This rule disallows the unary operators ++ and --.
- no-redeclare : This rule is aimed at eliminating variables that have multiple declarations in the same scope.
- no-trailing-spaces : This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines.
- semi : This rule enforces consistent use of semicolons.
- no-array-constructor : This rule disallows Array constructors.
- no-new-object : This rule disallows Object constructors.
Lightning Component
- alt-require : The alt attribute of an
<img>
element must be present and alt attribute of area[href] and input[type=image] must have a value. - attr-lowercase : All attribute names must be in lowercase.
- attr-no-duplication : Elements cannot have duplicate attributes.
- attr-unsafe-chars : Attribute values cannot contain unsafe chars.
- attr-value-double-quotes : Attribute values must be in double quotes.
- attr-value-not-empty : All attributes must have values.
- href-abs-or-rel : An href attribute must be either absolute or relative.
- id-class-ad-disabled : The id and class attributes cannot use the ad keyword, it will be blocked by adblock software.
- id-class-value : The id and class attribute values must meet the specified rules.
- id-unique : The value of id attributes must be unique.
- inline-script-disabled : Inline script cannot be used.
- inline-style-disabled : Inline style cannot be used.
- jshint : Scan script with jshint.
- space-tab-mixed-disabled : Do not mix tabs and spaces for indentation.
- spec-char-escape : Special characters must be escaped.
- src-not-empty : The src attribute of an img(script,link) must have a value.
- style-disabled :
<style>
tags cannot be used. - tag-pair : Tag must be paired.
- tag-self-close : Empty tags must be self closed.
- tagname-lowercase : All html element names must meet the camelCase style.
How to report bugs
You can create a new issue in GitHub and describe your problem or suggestion.
License
This project is licensed under the MIT License. Copyright (c) 2017-2018 Xenotime < [email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.