CodeSanity 2.18.0
Welcome to CodeSanity - created and maintained by Sascha Wildgrube.
Features
The CodeSanity app contains a number of instance scan checks to validate source code and other application files.
The CodeSanity scan suite can act as the foundation and master source for a coding guideline document.
Execution rules can be used to control which checks run on which applications and which do not.
CodeSanity checks are intended to scan applications (and the contained application files) - it is not intended to scan data or OOTB components - let alone the whole instance.
The CodeSanity checks shall start a discussion in the development team. Which checks are to be used? Which are not? What additional checks should be created?
Disclaimer
CodeSanity is NOT an officially supported ServiceNow product.
CodeSanity does NOT come with any kind of warranty. If you use it, you own it!
System Requirements
Installation
- Create an account on GitHub - if not done already.
- Create a personal access token for your GitHub account.
- Add credentials to access GitHub - use "Basic Auth".
- Fork the repository https://github.com/saschawildgrube/servicenow-devtools.
- Go to Studio and import the DevTools application from source control.
- Perform all installation steps for the DevTools application documented here: https://www.wildgrube.com/servicenow-devtools
- Fork the repository https://github.com/saschawildgrube/servicenow-codesanity.
- Go to Studio and import the CodeSanity application from source control.
- Execute installation scripts.
Run the following script as a background script in scope x_snc_codesanity: x_snc_devtools.InstallApp("x_snc_codesanity");
- Set the sn_atf.runner.enabled system property to "true" to activate the ATF test execution - if not set already.
- On non-production instances: Run the CodeSanity test suite.
Instance Scan checks contained in the CodeSanity app
Testing the CodeSanity scan suite
Each CodeSanity check comes with a corresponding ATF test to ensure its function. All tests are part of the CodeSanity test suite. The check "CodeSanity - ATF tests for checks" verifies that there is an ATF test for each CodeSanity check.
Adding checks to the CodeSanity scan suite
- Change the scope to the app which should contain your new check - this should NOT be the CodeSanity app. If you do not yet have a separate app, create one first.
- Navigate to the "CodeSanity" menu.
- Select "Add new check" in the menu.
- Create and save the new check - it will automatically be added to the CodeSanity scan suite.
Execution rules
In a larger developer community there might be variations in the coding guideline. Each and every project might have different rules - sometimes because a coding guideline has been introduced when many applications are already built or just because there are special considerations or coding patterns in use in a project.
Execution rules can be used to define which checks in the CodeSanity scan suite should run on which records and which should not.
Blacklisting
Blacklisting rules specify which checks should NOT run on records in specific app scopes. Use blacklisting rules if there are checks that just do not apply to one or more applications or which should be deactivated completely.
Whitelisting
Whitelisting rules specify checks that should ONLY run on records in specific app scopes. Use whitelisting rules if there are checks that only apply to one or more applications.
Whitelisting rules override blacklisting rules.
Setup
Follow these steps to set up execution rules:
- If not done already create a new application that contains the execution rules.
- Open the new app in Studio.
- Create a script include based on the CodeSanity extension point example code.
- Modify the function GetExecutionRules() - the examples demonstrate how it works.
- Create an extension point implementation and link it to the script include and the CodeSanity extension point.
Checks and scopes can be referenced by Sys Id or by their name. Both options obviously have pros and cons. Sys Ids are not going to change, but names are easier to read - a tough decision.
Creating a Coding Guideline document
CodeSanity checks can become the foundation of a Coding Guideline document.
An example Coding Guideline document can be found here: Coding Guideline. You can use the same mechanism to integrate the content in your own UI pages or create a document of your own.
The CodeSanity app contains the function HtmlRenderCodingGuideline which outputs the descriptions of all checks contained in the CodeSanity scan suite so that they can be integrated into an html page. Follow these steps to create a UI page that can act as the organization's Coding Guideline document:
- Switch the scope to the app that should contain the new UI page - this should NOT be "CodeSanity".
- Create a new UI page.
- Add the following code to the html template of the UI page:
<g2:no_escape>$[x_snc_codesanity.HtmlRenderCodingGuideline();]</g2:no_escape>
The output of the UI page can then be transferred into a corporate wiki or the ui page acts as the coding guideline document itself.
There might be guidelines which are difficult to check mechanically. However a check could be created that does not produce any findings but that contains the documentation of the guideline. CodeSanity checks may hence become the master source for all coding guidelines - no matter if they can be checked mechanically or not.
Limitations and Caveats
- Under yet unspecified circumstances a suite scan triggered via the "Execute Scan Suite" button on the suite form against an app may not produce all relevant findings. The ServiceNow product development team is made aware of that problem. Use the "CodeSanity Scan" button on the application form instead!
- Instance Scan does not work with scripts in Flow Designer. When scripted action steps are used such scripts are not considered in scans. The ServiceNow product development team is made aware of that problem.
- Instance Scan does not allow to run multiple scans at the same time. This may annoy larger development teams when multiple developers try to scan applications or individual application files at the same time.
- Instance Scan linter checks do not support ECMAScript 2021 classes.
How to unblock Instance Scan?
On rare occasions an Instance Scan run does not finish properly and remains in an undefined state. This prevents further Instance Scan checks to run. Follow these instructions to unblock Instance Scan and to enable further scan operations:
- Navigate to the list of active transactions.
- If there is a transaction of Type "instance_scan", select it and choose "Kill".
- Navigate to the Scan Results list.
- Check if there is a Scan Result record in status "In Progress". Delete this Scan Result record.
- Navigate to the Progress Workers list.
- Check if there is a Progress Worker record with name "Instance Scan" in state "Running". Delete this Progress Worker record.
- Navigate to the Execution Trackers list.
- Check if there is an Execution Tracker record with name "Instance Scan" and completion time "empty". Delete this Execution Tracker record.
Helpful links on Instance Scan
Reference
UI Actions
Configuration Options
Extension Points
- CodeSanity
The extension point allows to define additional execution rules.
The function GetExecutionRules() can set (or remove) rules that will be considered by all CodeSanity checks.
var CodeSanity = Class.create();
CodeSanity.prototype = {
initialize: function()
{
},
GetExecutionRules: function(rules)
{
// To disable the check "CodeSanity - Throwing exceptions" on scope "x_your_scope"
rules.blacklist.push(
{
scopes : ['x_your_scope'],
checks : ['CodeSanity - Throwing exceptions'],
});
// To disable the check "CodeSanity - Bracket-dot anti-pattern"
rules.blacklist.push(
{
all: true,
checks : ['CodeSanity - Bracket-dot anti-pattern'],
});
// To run the check "CodeSanity - Your specific check" only in scope "x_your_scope" and scope "x_your_other_scope"
rules.whitelist.push(
{
scopes : ['x_your_scope','x_your_other_scope'],
checks : ['CodeSanity - Your specific check'],
});
return rules;
},
type: 'CodeSanity'
};
Script Includes
- AppGetDependencies
Retrieves information about the app's dependencies to other apps and required versions.
- AppGetProperty
Gets a system property of this application.
- AppInstall
This script installs CodeSanity.
- AppSetDefaults
Sets all system properties to default values.
- AppSetProperty
Sets a system property of this application.
- CodeSanityClientAPI
The CodeSanityClientAPI class contains CodeSanity functions to be called from client side code.
- Debug
Produces a log output in the application log using the DevTools Debug function.
- DevTools
Implements the extension point for DevTools.
- DevToolsGetApplicationStatus
The DevToolsGetApplicationStatus is called by the DevTools extension point instance class and returns the application status object with additional status information to be displayed on the Application overview page.
- DevToolsGetFormatConfig
The DevToolsGetFormatConfig function is called by the DevTools extension point instance class and returns an object with field formatting information.
- DevToolsGetInstancePipelineName
The function DevToolsGetInstancePipelineName is called by the DevTools extension point instance class and returns the pipeline name of an instance based on the given actual name.
- DevToolsGetLinkDirectory
The DevToolsGetLinkDirectory function is called by the DevTools extension point instance class and returns an extended (or modified) link directory object that serves as the basis for the DevTools Link page.
- DevToolsGetParentRecord
The DevToolsGetParentRecord function is called by the DevTools extension point instance class and returns a parent record for the given record if it can be determined.
- DevToolsRenderDebugDump
The function DevToolsRenderDebugDump is called by the DevTools extension point instance class and returns additional debug information provided by the application.
- GetExecutionRules
Retrieves all available execution rules which other apps may inject using the CodeSanity extension point.
- GetLatestResultRecordForApp
Returns the latest available scan result record for a given app, if it exists, otherwise false.
- GetScanSourceRecord
Returns the one and only scan source record that refers to the CodeSanity scan suite record.
- GetScanSuiteRecord
Returns the one and only scan suite contained in the CodeSanity app.
- HtmlRenderCodingGuideline
Renders detailed descriptions of all checks contained in the CodeSanity suite so that they can be integrated into a Coding Guideline document.
- IsActive
Returns true if the application is active, otherwise false.
- IsCheckApplicableToRecord
Returns true if the given check should be executed on the given record, false if not.
- IsCheckApplicableToRecordByRules
Returns true if the given check should be executed on the given record based on the given rules, false if not.
- IsCheckInCodeSanitySuite
Returns true if the given check is part of the CodeSanity scan suite, false if not.
- Log
Produces a log output in the application log.
- LogError
Produces an error log output in the application log.
- LogWarning
Produces a warning log output in the application log.
- ScanAppWithDependencies
Scans an app and all of its dependencies using the CodeSanity suite.
Dependencies
Technical Debts
No technical debt has been documented for this application.
License
Copyright 2022-2024 by Sascha Wildgrube
Licensed under the Apache License, Version 2.0 (the "License")
You may not use CodeSanity except in compliance with the License.
You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Release Notes
2.18.0 - 2024-11-29
- DevTools 1.107.0 is required because of IsValidSysId() now considers the OOTB sys_app_application "System Import Sets" - which avoids a false positive in check "CodeSanity - Modules must require a role".
- Added check "CodeSanity - Role has a valid name".
- Added check "CodeSanity - Client callable Script Includes".
- Check "CodeSanity - ATF tests for Script Includes" considers the "DevToolsAppVersionBaselineOnFinish" Script Include as an exception.
- Check "CodeSanity - ATF tests for Script Includes" considers all Script Includes ending with "WorkerAPI" as exceptions.
- Refactored check "CodeSanity - ATF tests for Script Includes" to use DevTools' GetTestRecord() function and thus to enforce the strict test naming convention.
- Added ATF test for IsCheckApplicableToRecord().
- Added ATF test for GetExecutionRulesForCheck().
- Improved ATF test for check "CodeSanity - Avoid roles ending with "_user"" as it failed sometimes when executed via REST API.
- Improved ATF test for check "CodeSanity - System Property description" as it failed sometimes when executed via REST API.
2.17.0 - 2024-10-11
- DevTools 1.102.0 is required.
- Added check "CodeSanity - REST API must have a default ACL".
- Added check "CodeSanity - REST API Resource default ACL".
- Added check "CodeSanity - REST API must have a short description".
- Added check "CodeSanity - REST API Resource must have a short description".
- Check "CodeSanity - Sys IDs in scripts" now considers scripts in Instance Scan checks as an exception.
- DevToolsGetApplicationStatus() no longer uses deprecated function x_snc_devtools.GetInstanceRecordURL().
2.16.0 - 2024-09-12
- DevTools 1.101.0 is required due to the improved InstanceScanIsRunning() function.
- Added check "CodeSanity - Persona role in ACLs".
- Added check "CodeSanity - Persona role in Menus".
- Added check "CodeSanity - Persona role in menu Modules".
- Added check "CodeSanity - Persona role in User Criteria".
- Added check "CodeSanity - Persona role in UI Action".
- Added check "CodeSanity - Persona role in Business Rule".
- Added check "CodeSanity - System Property description".
- Added check "CodeSanity - System Property name".
- Refactored check "CodeSanity - Avoid "Copy of"" for performance.
- UI Actions "CodeSanity Point Scan" and "CodeSanity Scan" were still visible if the system property x_snc_codesanity.active was set to false. This has been fixed.
2.15.0 - 2024-08-30
- CodeSanity is fully tested with Xanadu.
- Vancouver is no longer actively supported.
- DevTools 1.100.0 is required due to improved progress display when scanning an app and fixed findings that were concealed by accidently set sys_policy.
- Added check "CodeSanity - Persona role dependencies".
- Improved check "CodeSanity - UI Action must not mix client and server code" to avoid false positives and added more reasons not to use the mixed code pattern.
- Improved check "CodeSanity - AppInstall must not modify records directly" to avoid false positives.
- Check "CodeSanity - Forbidden column names" created false positives on records in tables derived from sys_dictionary - this has been fixed.
- Check "CodeSanity - Forbidden column names" now considers more reserved terms - including "switch" but allows an exception for DevTools.
- Check "CodeSanity - Throwing exceptions" considers DevTools' Script Include "CreateQRCodeRawData" as an exception.
- Check "CodeSanity - Constant array index anti-pattern" considers DevTools' Script Include "CreateQRCodeRawData" as an exception.
- UI Action "CodeSanity Point Scan" now displays a message when invoked on sys_dictionary records. It seems as if a defect in the GlideAPI prevents sys_dictionary records from being scanned directly.
- Added chapter "How to unblock Instance Scan?".
- Added dependencies and technical debts to the manual.
2.14.0 - 2024-07-09
- DevTools 1.92.0 is now required due to improved logic to prevent useless checks.
- Added check "CodeSanity - UI Action onClick function naming".
- Added check "CodeSanity - UI Action must not mix client and server code".
- Check "CodeSanity - ATF tests for Script Includes" considers the "AppCreateTestData" Script Include as an exception.
2.13.1 - 2024-05-22
- AppInstall() now sets glide.scan.process_check.time_out correctly to 3 hours.
2.13.0 - 2024-05-17
- DevTools 1.81.0 is now required due to a bugfix in ScriptRemoveComments().
- Utah is no longer actively supported.
- CodeSanity is fully tested with Washington.
- Added check "CodeSanity - Forbidden column names".
- Check "CodeSanity - Script Include must contain a class or function" has been improved to avoid false positives.
- Check "CodeSanity - UI Action must have a unique Action name" now considers UI Actions that override other UI Actions.
- Wording in check "CodeSanity - UI Action must have a unique Action name" has been improved to better explain why unique Action names are recommended.
- AppInstall() now sets the system property "glide.scan.process_check.time_out" to 3 hours to prevent timeout errors during scanning.
- Added a description to the "CodeSanity" scan suite.
- Updated the Instance Scan documentation link in the manual's link section.
2.12.0 - 2024-01-18
- Tokyo is no longer actively supported.
- CodeSanity has been fully tested in Vancouver.
- The OOTB UI Action "Run Point Scan" is deactivated by setting the "glide.scan.enable_point_scan_ui_action" to false.
- The OOTB UI Action "Scan Application" is deactivated.
- Added check "CodeSanity - AppInstall must not modify records directly".
- Check "CodeSanity - Sys IDs in scripts" considers any Script Includes that start with "AppInstall" as exceptions. This allows to use sub functions in AppInstall() scripts.
- Check "CodeSanity - Script Include must contain a class or function" now copes well with all kinds of comments in the source code.
2.11.0 - 2023-11-14
- Added check "CodeSanity - UI Action must have a unique Action name".
- Added check "CodeSanity - Data Sources must not contain credentials".
- Added check "CodeSanity - LDAP Server Configs must not contain credentials".
- Check "CodeSanity - ATF tests for Script Includes" considers the "AppBaseline" Script Include as an exception.
- Check "CodeSanity - Sys IDs in scripts" considers the "AppBaseline" and "AppSetDefaults" Script Includes as exceptions.
- Check "CodeSanity - Client-side logging" now considers the UI Script "x_snc_devtools.LogError" as an exception.
- Checks "CodeSanity - * checks must apply execution rules" and "CodeSanity - Table check code pattern" now ignore comments in the scripts.
- Improved description for check "CodeSanity - ATF test must be in an ATF suite".
- Improved resolution details for check "CodeSanity - AppInstall".
2.10.0 - 2023-07-28
- DevTools 1.65.0 is now required.
- Added check "CodeSanity - ATF suite name is unique".
- Added check "CodeSanity - ATF test name is unique".
- The check "CodeSanity - ATF tests for script includes" now considers the "DevToolsGetInstancePipelineName", "LogError" and "LogWarning" Script Includes as exceptions.
- The check "CodeSanity - Avoid arrow functions" no longer produces false positives if "=>" is contained in comments and string literals.
- The check "CodeSanity - Complex scripts in the right place" now makes a difference between high complexity scripts (more than 80 lines) and medium complexity scripts (more than 40 lines).
- The check "CodeSanity - Complex scripts in the right place" now considers x_snc_reactor_component records as high complexity scripts.
- The check "CodeSanity - Complex scripts in the right place" now considers records in sys_ui_action and sys_ws_operation as medium complexity scripts.
- The check "CodeSanity - Sys IDs in scripts" now considers x_snc_devtools.AppSanity() as an exception.
- A defect caused a blacklisted check to appear in the coding guideline. This has been fixed.
- The documentation of check "CodeSanity - Script Include must contain a class or function" has been improved.
2.9.0 - 2023-04-14
- DevTools 1.60.0 is now required.
- San Diego is no longer actively supported.
- CodeSanity is now fully tested in Utah.
- Added check "CodeSanity - Complex scripts in the right place".
- Check "CodeSanity - Comment containing "TODO"" no longer creates findings if the TODO pattern is within a string literal.
- Check "CodeSanity - Bracket-dot anti-pattern" no longer creates findings if the anti-pattern contained in a string literal.
- Check "CodeSanity - Debug output" no longer creates findings of debug output statements are contained in a string literals.
- Check "CodeSanity - ATF test must contain steps" now checks if steps are active.
- Check "CodeSanity - ATF suite contains at least one test" now also considers child test suites.
- Removed the log.active system property.
2.8.0 - 2023-03-07
- DevTools 1.56.0 is now required.
- Added check "CodeSanity - AppInstall".
- Added check "CodeSanity - Client-side logging".
- Added check "CodeSanity - UI Action requires a role".
- Added check "CodeSanity - UI Action must have a unique onClick function".
- Added check "CodeSanity - Business Rule description".
- Added check "CodeSanity - Avoid roles ending with "_user"".
- Added check "CodeSanity - ATF test must contain steps".
- Added check "CodeSanity - Application menu must have modules".
- Added check "CodeSanity - Comment containing "TODO"".
- Added check "CodeSanity - Role description".
- The check "CodeSanity - Avoid "Copy of"" has been refactored to filter for a specific list of classes to be scanned (instead of all except some exceptions). This is to counter a potential performance issue.
- The check "CodeSanity - logging.verbosity system property" no longer executes on global scoped applications.
- The check "CodeSanity - App must have a manual page" no longer executes on global scoped applications.
- The check "CodeSanity - Bracket-dot anti-pattern" does no longer produce a finding for the use of "sn_fd.Flow_API.getRunner()", as this pattern is proposed by ServiceNow (unfortunately).
- UI Action "CodeSanity Point Scan" now requires the "scan_user" role.
- Added function ScanAppWithDependencies().
- Added ATF test for function PrepareNewCheck().
- Added ATF test for function LogBeanCount().
- Added ATF test for function HtmlRenderCodingGuideline().
2.7.0 - 2023-01-26
- DevTools 1.54.0 is now required.
- Added check "CodeSanity - Avoid ATF suite schedules".
- Added UI action "CodeSanity Point Scan" to scan a single record against the CodeSanity scan suite.
- All UI actions are only visible if the system property "x_snc_codesanity.active" is set to true.
- Added business rule "scan_result - Log bean count" to log the bean count at the end of a scan.
- The check "CodeSanity - Avoid "Copy of"" is no longer executed on records in sys_hub_flow_variable, sys_scope_privilege, sys_atf_input_variable, sys_atf_step, sys_properties_category_m2m, x_snc_devtools_dependency, sys_extension_instance.
- The new system property "x_snc_codesanity.log.beancount.frequency" now controls the frequency of the beancount log output during a scan.
- Added ATF for function GetLinkDirectoryInstanceScan().
2.6.0 - 2023-01-17
- Added check "CodeSanity - App must have a manual page".
- Added function BeanCounter() to count all checks per check and by tables.
- The check "CodeSanity - ATF tests for script includes" now considers the "DevToolsRenderDebugDump" script include as an exception.
- The check "CodeSanity - Avoid "Copy of"" is no longer executed on records in sys_metadata_delete and sys_security_acl.
2.5.0 - 2023-01-06
- DevTools 1.52.0 is now required.
- Added check "CodeSanity - ATF suite contains at least one test".
- Added check 'CodeSanity - Avoid "Copy of"'.
- Added check "CodeSanity - Deprecated logging".
- Added check 'CodeSanity - Avoid "Utils" classes'.
- The application overview page now shows the duration of the last scan in minutes.
- The check "CodeSanity - App documentation" now verifies if a valid url has been provided for the documentation and repository links.
- The check "CodeSanity - ATF tests for script includes" now excludes "ClientAPI" script includes which are client callable.
- Added function GetScanSourceRecord().
- Added function GetLatestResultRecordForApp().
- Function GetScanSuiteRecord() is now accessible from all scopes.
- Added ATF for function IsCheckInCodeSanitySuite().
- AppInstall() now sets the "Scan timeout" transaction quota rule to 6 hours.
- AppInstall() now sets the no_truncate attribute on the scan_combo.targets column to avoid application names to be cut off in the list view.
2.4.0 - 2022-12-23
- DevTools 1.51.0 is now required.
- CodeSanity now supports the "DevTools Application Overview" page and displays the date and amount of findings of the most recent CodeSanity scan.
- Added check "CodeSanity - Avoid the spread operator".
- Added check "CodeSanity - Do not use fix scripts".
- Check "CodeSanity - App documentation" now detects invalid maintainer email addresses.
- Check "CodeSanity - Script Include description" treats the AppBuilder() function as an exception as it is only for internal use.
- Check "CodeSanity - Application ATF test suite" now runs on sys_app instead of sys_scope.
- Check "CodeSanity - ATF tests for script includes" treats the new DevToolsGetApplicationStatus() function as an exception.
- The UI action "CodeSanity Scan" now checks if a scan is already running using the UI script function InstanceScanIsRunning().
- Added the coding guideline page.
- Added ATF test for GetScanSuiteRecord().
- ATF for check "CodeSanity - Application ATF test suite" now uses ad-hoc test data to provoke a finding.
2.3.0 - 2022-11-30
- DevTools 1.48.0 is now required.
- Added check "CodeSanity - Script Include description".
- Added check "CodeSanity - UI Script description".
- The UI action "CodeSanity Scan" now handles already running Instance Scans properly.
- The function IsCheckApplicableToRecord() is now using DevTools IsTestRunning() to determine whether an instance scan check is executed as part of an ATF. This allows to test checks via ATF even if they are blacklisted.
- Added ATF test for function GetAppIdentifiers().
2.2.0 - 2022-11-29
- DevTools 1.47.0 is now required.
- Tokyo is now actively supported.
- Added the UI action "CodeSanity Scan" to the custom application form.
- Renamed the CodeSanity category to "CodeSanity".
- Added check "CodeSanity - App documentation".
- Added check "CodeSanity - ATF test must be in an ATF suite".
- Added check "CodeSanity - ATF tests for script includes".
- The check "CodeSanity - Constant array index anti-pattern" produced false positives on string literals that contained the pattern. This has been fixed.
- Improved documentation in check "CodeSanity - Constant array index anti-pattern".
- The check "CodeSanity - Script include must contain a class or function" now also supports modern JavaScript class syntax as supported starting with Tokyo.
- The scan result list now uses an improved list layout displaying more details on the scan.
- The coding guideline is now rendered using "clean" application names (without "WORK IN PROGRESS" post-fixes).
- Added UI actions to the manual.
- Added system properties to the manual.
- Added ATF test for function GetAppIdentifier().
2.1.0 - 2022-11-02
- Execution rules now also support application names of global scoped apps.
- Added check "CodeSanity - GlideRecord without new".
- Added check "CodeSanity - Application ATF Test Suite".
- Added check "CodeSanity - Avoid engine.current".
- Added check "CodeSanity - Modules must require a role".
- The check "CodeSanity - Avoid arrow functions" was inactive and not effective. This has been fixed.
- The check "CodeSanity - Sys IDs in scripts" does no longer check Fix Scripts (sys_script_fix).
- The check "CodeSanity - Sys IDs in scripts" now detects simple obfuscation strategies (i.e. splitting a sys_id in two or more concatenated strings).
- The check "CodeSanity - Application names in code" now considers a few exceptions as a view name may be the same as an application name - this covers sysrule_view records and a limited number of script includes.
- The check "CodeSanity - String concatenation anti-pattern" has been removed as it turned out not to provide any real value.
- The code template used when adding a new check has been improved.
- When creating a new check, the priority is set to 1 by default.
- AppInstall() now also executes DevTools' AppInstall() function.
- Removed the function HtmlRenderOtherInstanceScanChecks().
- Improved performance of GetExecutionRules() by using transaction caching.
- Improved installation instructions contained in the manual.
2.0.1 - 2022-08-25
- A defect in IsCheckApplicableToRecord() caused checks not to run which are part of another scope than CodeSanity. This has been fixed.
2.0.0 - 2022-08-18
- DevTools 1.42.0 is now required.
- Introducing the "Execution Rules" feature to control which checks should run on which records - this requires ALL CodeSanity checks to use new function IsCheckApplicableToRecord() to check if the check should run on the given record.
- Added guidance to the manual on how to create a coding guideline document based on CodeSanity checks.
- The function HtmlRenderCodingGuideline() now also renders the execution rules that apply to a check.
- When adding a new check the script field is prepopulated with the essential logic of a CodeSanity check.
- Added check "CodeSanity - CodeSanity table checks apply rules" to make sure all CodeSanity table checks use the new function IsCheckApplicableToRecord().
- Added check "CodeSanity - CodeSanity linter checks apply rules" to make sure all CodeSanity linter checks use the new function IsCheckApplicableToRecord().
- Added check "CodeSanity - CodeSanity column type checks apply rules" to make sure all CodeSanity column type checks use the new function IsCheckApplicableToRecord().
- Added check "CodeSanity - Checks must be tested using ATF" to ensure that all checks are covered by ATF tests.
- Added check "CodeSanity - Temporary tables" to test if there are temporary import tables left.
- Added check "CodeSanity - Do not run flows from scripts" to make sure that no script triggers flows or subflows.
- Priority of new checks is set to "Critical" by default.
- Added function IsCheckApplicableToRecord() to check if a check whould be applied to the given record.
- Added extension point "CodeSanity" including the GetExecutionRules() function and added GetExecutionRules() function to collect execution rules from multiple extension point implementations.
- The function HtmlRenderCodingGuideline() now renders line breaks in check descriptions properly.
- Added ATF tests for various checks.
- Updated manual on testing the CodeSanity scan suite.
1.6.0 - 2022-07-27 - Birthday Edition
- Added check "CodeSanity - Script include has a valid name".
- Added check "CodeSanity - InstallerAPI without context".
- Added check "CodeSanity - Avoid arrow functions". Although arrow functions are not yet supported in ServiceNow.
- Added check "CodeSanity - Widget checks for input".
- The check "Checks for the bracket-dot anti-pattern" now allows the pattern "gs.getUser()." because we can assume that gs.getUser() always returns GlideUser object.
- The check "Checks for the bracket-dot anti-pattern" now allows patterns like "$('needle')." to support jquery in sp_widget client code.
- Renamed check "CodeSanity - [0] anti-pattern" to "CodeSanity - Constant array index anti-pattern".
- Added the function HtmlrenderCodingGuideline() to produce ui pages that can serve as a coding guideline document.
- This manual page no longer shows instance scan checks that are contained in other apps.
1.5.0 - 2022-07-08
- DevTools 1.40.0 is now required.
- Check "CodeSanity - Bracket-dot anti-pattern" is now making an exception for sp_widget records to allow the pattern: "server.update().then(".
- Check "CodeSanity - Sys IDs in scripts" has been updated to check only against letters from 'a' to 'f'.
- Check "CodeSanity - String concatenation anti-pattern" now allows concatenated strings if the second string starts with a backslash and hence indicates an escaped character.
1.4.0 - 2022-06-12
- DevTools 1.39.0 is now required.
- Added check "CodeSanity - logging.verbosity system property".
- The check "CodeSanity - Script include must contain a class or function" was improved to avoid false negatives.
- The check "CodeSanity - Throwing exceptions" was improved to avoid false positives.
- Added the "logging.verbosity" system property.
- Added first ATF tests to verify the checks and removed the "AntiPattern" script includes.
1.3.0 - 2022-06-10
- Added the check "CodeSanity - UI Actions without comments".
- The check "CodeSanity - Application names in code" now considers the AppInstall() function as an exception.
- The check "CodeSanity - Script include must contain a class or function" is now considering comments at the top of the script.
1.2.0 - 2022-05-31
- DevTools 1.38.0 is now required.
- Added check "CodeSanity - Script include must contain a class or function".
- Added check "CodeSanity - Table check code pattern".
- The check against application names in code now considers application name postfixes (like "WORK IN PROGRESS" etc.).
- The check against application names in code now considers specific code patterns as exceptions where it is unlikely that the string is actually the application name - i.e. where the string is more likely a class name or the name of an extension point.
- The check against application names in code now considers the function x_snc_codesanity.GetScanSuiteRecord() and any script include containing "GetLinkDirectory" in the name as an exception.
- The check against the [0] anti pattern is now considering any constant number pre or postfixed by whitespace characters.
- More exceptions have been added for the check against Sys IDs in scripts.
1.1.0 - 2022-04-19
- DevTools 1.37.0 is now required.
- Priority of all checks is now set to "Critical".
- Refactored CodeSanity's own code not to trigger any findings other than in the honey pot script include "AntiPatterns".
- Added a check against the use of application names in source code.
- Added a check if the field "short_description" is used in a condition statement.
- Added a check against using the Date class constructor without parameters.
- Added a check against the bracket-dot anti-pattern.
- Added a check against the string concatenation anti-pattern.
- Several exceptions have been added for the check against Sys IDs in scripts as some specific functions will need to contain Sys IDs no matter what.
- Corrected a defect in the check against Sys IDs in source code.
1.0.0 - 2022-03-15
First baselined version