Skip to content

Added Experience Cloud to SIT #50

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

Open
wants to merge 15 commits into
base: sit
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_COVERAGE.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def calculate_coverage(file_path):

total_lines = 0
covered_lines = 0
coverage_threshold = 80
coverage_threshold = 50
failed_classes = []

# Coverage for each class
Expand Down
1 change: 1 addition & 0 deletions force-app/main/default/classes/AccountHandler.cls
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
public with sharing class AccountHandler {
public static void run() {
System.debug('Hello');

Check warning on line 3 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel

Check warning on line 3 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel
}

Check warning on line 4 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Missing ApexDoc comment

This rule validates that: * ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes). * ApexDoc comments are present for classes, methods, and properties that are protected or private, depending on the properties `reportPrivate` and `reportProtected`. * ApexDoc comments should contain @description depending on the property `reportMissingDescription`. * ApexDoc comments on non-void, non-constructor methods should contain @return. * ApexDoc comments on void or constructor methods should not contain @return. * ApexDoc comments on methods with parameters should contain @param for each parameter, in the same order as the method signature. * ApexDoc comments are present on properties is only validated, if the property `reportProperty` is enabled. By setting `reportProperty` to false, you can ignore missing comments on properties. Method overrides and tests are both exempted from having ApexDoc. ApexDoc (Priority: 3, Ruleset: Documentation) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_documentation.html#apexdoc

Check warning on line 4 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Missing ApexDoc comment

This rule validates that: * ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes). * ApexDoc comments are present for classes, methods, and properties that are protected or private, depending on the properties `reportPrivate` and `reportProtected`. * ApexDoc comments should contain @description depending on the property `reportMissingDescription`. * ApexDoc comments on non-void, non-constructor methods should contain @return. * ApexDoc comments on void or constructor methods should not contain @return. * ApexDoc comments on methods with parameters should contain @param for each parameter, in the same order as the method signature. * ApexDoc comments are present on properties is only validated, if the property `reportProperty` is enabled. By setting `reportProperty` to false, you can ignore missing comments on properties. Method overrides and tests are both exempted from having ApexDoc. ApexDoc (Priority: 3, Ruleset: Documentation) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_documentation.html#apexdoc
public static void flush() {
System.debug('Hello');

Check warning on line 6 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel

Check warning on line 6 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel
System.debug('Hello');

Check warning on line 7 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel

Check warning

Code scanning / PMD

Calls to System.debug should specify a logging level. Warning

Calls to System.debug should specify a logging level.

Check warning on line 7 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel
}

Check warning on line 8 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Missing ApexDoc comment

This rule validates that: * ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes). * ApexDoc comments are present for classes, methods, and properties that are protected or private, depending on the properties `reportPrivate` and `reportProtected`. * ApexDoc comments should contain @description depending on the property `reportMissingDescription`. * ApexDoc comments on non-void, non-constructor methods should contain @return. * ApexDoc comments on void or constructor methods should not contain @return. * ApexDoc comments on methods with parameters should contain @param for each parameter, in the same order as the method signature. * ApexDoc comments are present on properties is only validated, if the property `reportProperty` is enabled. By setting `reportProperty` to false, you can ignore missing comments on properties. Method overrides and tests are both exempted from having ApexDoc. ApexDoc (Priority: 3, Ruleset: Documentation) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_documentation.html#apexdoc

Check warning on line 8 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Missing ApexDoc comment

This rule validates that: * ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes). * ApexDoc comments are present for classes, methods, and properties that are protected or private, depending on the properties `reportPrivate` and `reportProtected`. * ApexDoc comments should contain @description depending on the property `reportMissingDescription`. * ApexDoc comments on non-void, non-constructor methods should contain @return. * ApexDoc comments on void or constructor methods should not contain @return. * ApexDoc comments on methods with parameters should contain @param for each parameter, in the same order as the method signature. * ApexDoc comments are present on properties is only validated, if the property `reportProperty` is enabled. By setting `reportProperty` to false, you can ignore missing comments on properties. Method overrides and tests are both exempted from having ApexDoc. ApexDoc (Priority: 3, Ruleset: Documentation) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_documentation.html#apexdoc
public static void sleep() {
System.debug('Hello');

Check warning on line 10 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel

Check warning on line 10 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Calls to System.debug should specify a logging level.

The first parameter of System.debug, when using the signature with two parameters, is a LoggingLevel enum. Having the Logging Level specified provides a cleaner log, and improves readability of it. DebugsShouldUseLoggingLevel (Priority: 3, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#debugsshoulduselogginglevel
/* Generate the code to create the Account Record*/
Account acc = new Account();
acc.Name = 'PantherSchools.com';
insert acc;

Check warning on line 14 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Validate CRUD permission before SOQL/DML operation

The rule validates you are checking for access permissions before a SOQL/SOSL/DML operation. Since Apex runs by default in system mode not having proper permissions checks results in escalation of privilege and may produce runtime errors. This check forces you to handle such scenarios. Since Winter '23 (API Version 56) you can enforce user mode for database operations by using `WITH USER_MODE` in SOQL. This makes Apex to respect Field-level security (FLS) and object permissions of the running user. When using user mode, no violation is reported by this rule. By default, the rule allows access checks can be performed using system Apex provisions such as `DescribeSObjectResult.isAccessible/Createable/etc.`, the SOQL `WITH SECURITY_ENFORCED` clause, or using the open source [Force.com ESAPI](https://github.com/forcedotcom/force-dot-com-esapi) class library. Because it is common to use authorization facades to assist with this task, the rule also allows configuration of regular expression-based patterns for the methods used to authorize each type of CRUD operation. These pattern are configured via the following properties: * `createAuthMethodPattern`/`createAuthMethodTypeParamIndex` - a pattern for the method used for create authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for create. * `readAuthMethodPattern`/`readAuthMethodTypeParamIndex` - a pattern for the method used for read authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for read. * `updateAuthMethodPattern`/`updateAuthMethodTypeParamIndex` - a pattern for the method used for update authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for update. * `deleteAuthMethodPattern`/`deleteAuthMethodTypeParamIndex` - a pattern for the method used for delete authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for delete. * `undeleteAuthMethodPattern`/`undeleteAuthMethodTypeParamIndex` - a pattern for the method used for undelete authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for undelete. * `mergeAuthMethodPattern`/`mergeAuthMethodTypeParamIndex` - a pattern for the method used for merge authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for merge. The following example shows how the rule can be configured for the [sirono-common](https://github.com/SCWells72/sirono-common) [`AuthorizationUtil`](https://github.com/SCWells72/sirono-common#authorization-utilities) class: ```xml <rule ref="category/apex/security.xml/ApexCRUDViolation" message="Validate CRUD permission before SOQL/DML operation"> <priority>3</priority> <properties> <property name="createAuthMethodPattern" value="AuthorizationUtil\.(is|assert)(Createable|Upsertable)"/> <property name="readAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Accessible"/> <property name="updateAuthMethodPattern" value="AuthorizationUtil\.(is|assert)(Updateable|Upsertable)"/> <property name="deleteAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Deletable"/> <property name="undeleteAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Undeletable"/> <property name="mergeAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Mergeable"/> </properties> </rule> ``` Note: This rule will produce false positives for VF getter methods. In VF getters the access permission check happens automatically and is not needed explicitly. However, the rule can't reliably determine whether a getter is a VF getter or not and reports a violation in any case. In such cases, the violation should be [suppressed](pmd_userdocs_suppressing_warnings.html). ApexCRUDViolation (Priority

Check warning on line 14 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Validate CRUD permission before SOQL/DML operation

The rule validates you are checking for access permissions before a SOQL/SOSL/DML operation. Since Apex runs by default in system mode not having proper permissions checks results in escalation of privilege and may produce runtime errors. This check forces you to handle such scenarios. Since Winter '23 (API Version 56) you can enforce user mode for database operations by using `WITH USER_MODE` in SOQL. This makes Apex to respect Field-level security (FLS) and object permissions of the running user. When using user mode, no violation is reported by this rule. By default, the rule allows access checks can be performed using system Apex provisions such as `DescribeSObjectResult.isAccessible/Createable/etc.`, the SOQL `WITH SECURITY_ENFORCED` clause, or using the open source [Force.com ESAPI](https://github.com/forcedotcom/force-dot-com-esapi) class library. Because it is common to use authorization facades to assist with this task, the rule also allows configuration of regular expression-based patterns for the methods used to authorize each type of CRUD operation. These pattern are configured via the following properties: * `createAuthMethodPattern`/`createAuthMethodTypeParamIndex` - a pattern for the method used for create authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for create. * `readAuthMethodPattern`/`readAuthMethodTypeParamIndex` - a pattern for the method used for read authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for read. * `updateAuthMethodPattern`/`updateAuthMethodTypeParamIndex` - a pattern for the method used for update authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for update. * `deleteAuthMethodPattern`/`deleteAuthMethodTypeParamIndex` - a pattern for the method used for delete authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for delete. * `undeleteAuthMethodPattern`/`undeleteAuthMethodTypeParamIndex` - a pattern for the method used for undelete authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for undelete. * `mergeAuthMethodPattern`/`mergeAuthMethodTypeParamIndex` - a pattern for the method used for merge authorization and an optional 0-based index of the parameter passed to that method that denotes the `SObjectType` being authorized for merge. The following example shows how the rule can be configured for the [sirono-common](https://github.com/SCWells72/sirono-common) [`AuthorizationUtil`](https://github.com/SCWells72/sirono-common#authorization-utilities) class: ```xml <rule ref="category/apex/security.xml/ApexCRUDViolation" message="Validate CRUD permission before SOQL/DML operation"> <priority>3</priority> <properties> <property name="createAuthMethodPattern" value="AuthorizationUtil\.(is|assert)(Createable|Upsertable)"/> <property name="readAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Accessible"/> <property name="updateAuthMethodPattern" value="AuthorizationUtil\.(is|assert)(Updateable|Upsertable)"/> <property name="deleteAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Deletable"/> <property name="undeleteAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Undeletable"/> <property name="mergeAuthMethodPattern" value="AuthorizationUtil\.(is|assert)Mergeable"/> </properties> </rule> ``` Note: This rule will produce false positives for VF getter methods. In VF getters the access permission check happens automatically and is not needed explicitly. However, the rule can't reliably determine whether a getter is a VF getter or not and reports a violation in any case. In such cases, the violation should be [suppressed](pmd_userdocs_suppressing_warnings.html). ApexCRUDViolation (Priority
}

Check warning on line 15 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Missing ApexDoc comment

This rule validates that: * ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes). * ApexDoc comments are present for classes, methods, and properties that are protected or private, depending on the properties `reportPrivate` and `reportProtected`. * ApexDoc comments should contain @description depending on the property `reportMissingDescription`. * ApexDoc comments on non-void, non-constructor methods should contain @return. * ApexDoc comments on void or constructor methods should not contain @return. * ApexDoc comments on methods with parameters should contain @param for each parameter, in the same order as the method signature. * ApexDoc comments are present on properties is only validated, if the property `reportProperty` is enabled. By setting `reportProperty` to false, you can ignore missing comments on properties. Method overrides and tests are both exempted from having ApexDoc. ApexDoc (Priority: 3, Ruleset: Documentation) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_documentation.html#apexdoc

Check warning on line 15 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Missing ApexDoc comment

This rule validates that: * ApexDoc comments are present for classes, methods, and properties that are public or global, excluding overrides and test classes (as well as the contents of test classes). * ApexDoc comments are present for classes, methods, and properties that are protected or private, depending on the properties `reportPrivate` and `reportProtected`. * ApexDoc comments should contain @description depending on the property `reportMissingDescription`. * ApexDoc comments on non-void, non-constructor methods should contain @return. * ApexDoc comments on void or constructor methods should not contain @return. * ApexDoc comments on methods with parameters should contain @param for each parameter, in the same order as the method signature. * ApexDoc comments are present on properties is only validated, if the property `reportProperty` is enabled. By setting `reportProperty` to false, you can ignore missing comments on properties. Method overrides and tests are both exempted from having ApexDoc. ApexDoc (Priority: 3, Ruleset: Documentation) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_documentation.html#apexdoc
public static void createRecords() {
String AccountName = 'pantherschools.com';

Check notice on line 17 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Variable 'AccountName' defined but not used

Detects when a local variable is declared and/or assigned but not used. UnusedLocalVariable (Priority: 5, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable

Check notice on line 17 in force-app/main/default/classes/AccountHandler.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Variable 'AccountName' defined but not used

Detects when a local variable is declared and/or assigned but not used. UnusedLocalVariable (Priority: 5, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable
System.debug('Hello');
/* Generate the code to create the Account Record using Async Apex*/
// Check if the user has the necessary permissions to create the record
Expand Down
12 changes: 12 additions & 0 deletions force-app/main/default/classes/CommunitiesLandingController.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
*/
public with sharing class CommunitiesLandingController {

// Code we will invoke on page load.
public PageReference forwardToStartPage() {
return Network.communitiesLanding();
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment

public CommunitiesLandingController() {}

Check warning

Code scanning / PMD

Avoid empty block statements. Warning

Avoid empty block statements.

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc @description
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@IsTest
public with sharing class CommunitiesLandingControllerTest {
@IsTest(SeeAllData=true)
public static void testCommunitiesLandingController() {
// Instantiate a new controller with all parameters in the page
CommunitiesLandingController controller = new CommunitiesLandingController();
PageReference pageRef = controller.forwardToStartPage();
//PageRef is either null or an empty object in test context
if(pageRef!= null){
String url = pageRef.getUrl();
if(url!= null){
System.assertEquals(true, String.isEmpty(url));

Check warning

Code scanning / PMD

'System.assert' should have 2 parameters. Warning

'System.assertEquals' should have 3 parameters.
//show up in perforce
}
}
}

Check warning

Code scanning / PMD

@isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by tests Warning

@isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by tests

Check warning

Code scanning / PMD

Apex unit test classes should have at least one System.runAs() call Warning

Apex unit test classes should have at least one System.runAs() call
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<status>Active</status>
</ApexTrigger>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
*/
public with sharing class CommunitiesSelfRegConfirmController {

public CommunitiesSelfRegConfirmController() {}

Check warning

Code scanning / PMD

Avoid empty block statements. Warning

Avoid empty block statements.

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc @description
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
*/
@IsTest public with sharing class CommunitiesSelfRegConfirmControllerTest {
@IsTest(SeeAllData=true) public static void testCommunitiesSelfRegConfirmController() {
// Instantiate a new controller with all parameters in the page
CommunitiesSelfRegConfirmController controller = new CommunitiesSelfRegConfirmController();

Check notice on line 7 in force-app/main/default/classes/CommunitiesSelfRegConfirmControllerTest.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Variable 'controller' defined but not used

Detects when a local variable is declared and/or assigned but not used. UnusedLocalVariable (Priority: 5, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable

Check warning

Code scanning / PMD

Variable 'roleEnum' defined but not used Warning

Variable 'controller' defined but not used

Check notice on line 7 in force-app/main/default/classes/CommunitiesSelfRegConfirmControllerTest.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Variable 'controller' defined but not used

Detects when a local variable is declared and/or assigned but not used. UnusedLocalVariable (Priority: 5, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable
}

Check warning

Code scanning / PMD

@isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by tests Warning

@isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by tests

Check warning

Code scanning / PMD

Apex unit test classes should have at least one System.assert() or assertEquals() or AssertNotEquals() call Warning

Apex unit test classes should have at least one System.assert() or assertEquals() or AssertNotEquals() call

Check warning

Code scanning / PMD

Apex unit test classes should have at least one System.runAs() call Warning

Apex unit test classes should have at least one System.runAs() call
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc @description
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<status>Active</status>
</ApexClass>
74 changes: 74 additions & 0 deletions force-app/main/default/classes/CommunitiesSelfRegController.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* An apex page controller that supports self registration of users in communities that allow self registration
*/
public class CommunitiesSelfRegController {

public String firstName {get; set;}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
public String lastName {get; set;}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
public String email {get; set;}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
public String password {get; set {password = value == null ? value : value.trim(); } }

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment

public CommunitiesSelfRegController() {
String expid = ApexPages.currentPage().getParameters().get('expid');
if (expId != null) {
Site.setExperienceId(expId);
}
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment

private boolean isValidPassword() {
return password == confirmPassword;
}

public PageReference registerUser() {

// it's okay if password is null - we'll send the user a random password in that case
if (!isValidPassword()) {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
ApexPages.addMessage(msg);
return null;
}

String profileId = null; // To be filled in by customer.
String roleEnum = null; // To be filled in by customer.

Check notice on line 34 in force-app/main/default/classes/CommunitiesSelfRegController.cls

View workflow job for this annotation

GitHub Actions / Validate to UAT / build

Variable 'roleEnum' defined but not used

Detects when a local variable is declared and/or assigned but not used. UnusedLocalVariable (Priority: 5, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable

Check warning

Code scanning / PMD

Variable 'roleEnum' defined but not used Warning

Variable 'roleEnum' defined but not used

Check notice on line 34 in force-app/main/default/classes/CommunitiesSelfRegController.cls

View workflow job for this annotation

GitHub Actions / Deploy to UAT / build

Variable 'roleEnum' defined but not used

Detects when a local variable is declared and/or assigned but not used. UnusedLocalVariable (Priority: 5, Ruleset: Best Practices) https://docs.pmd-code.org/pmd-doc-7.6.0/pmd_rules_apex_bestpractices.html#unusedlocalvariable
String accountId = ''; // To be filled in by customer.

String userName = email;

User u = new User();
u.Username = userName;
u.Email = email;
u.FirstName = firstName;
u.LastName = lastName;
u.CommunityNickname = communityNickname;
u.ProfileId = profileId;

String userId;

try {
userId = Site.createExternalUser(u, accountId, password);
} catch(Site.ExternalUserCreateException ex) {
List<String> errors = ex.getDisplayMessages();
for (String error : errors) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, error));
}

// This message is used for debugging. Do not display this in the UI to the end user.
// It has the information around why the user creation failed.
System.debug(ex.getMessage());

Check warning

Code scanning / PMD

Calls to System.debug should specify a logging level. Warning

Calls to System.debug should specify a logging level.
}

if (userId != null) {
if (password != null && password.length() > 1) {
return Site.login(userName, password, ApexPages.currentPage().getParameters().get('startURL'));
}
else {
PageReference page = System.Page.CommunitiesSelfRegConfirm;
page.setRedirect(true);
return page;
}
}
return null;
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc comment
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc @description
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* An apex page controller that supports self registration of users in communities that allow self registration
*/
@IsTest public with sharing class CommunitiesSelfRegControllerTest {
@IsTest(SeeAllData=true)
public static void testCommunitiesSelfRegController() {
CommunitiesSelfRegController controller = new CommunitiesSelfRegController();
controller.firstName = 'FirstName';
controller.lastName = 'LastName';
controller.email = '[email protected]';
controller.communityNickname = 'test';

// registerUser will always return null when the page isn't accessed as a guest user
System.assert(controller.registerUser() == null);

Check warning

Code scanning / PMD

'System.assert' should have 2 parameters. Warning

'System.assert' should have 2 parameters.

controller.password = 'abcd1234';
controller.confirmPassword = 'abcd123';
System.assert(controller.registerUser() == null);

Check warning

Code scanning / PMD

'System.assert' should have 2 parameters. Warning

'System.assert' should have 2 parameters.
}

Check warning

Code scanning / PMD

@isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by tests Warning

@isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by tests

Check warning

Code scanning / PMD

Apex unit test classes should have at least one System.runAs() call Warning

Apex unit test classes should have at least one System.runAs() call
}

Check warning

Code scanning / PMD

Missing ApexDoc @description Warning

Missing ApexDoc @description
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>62.0</apiVersion>
<status>Active</status>
</ApexClass>
2 changes: 1 addition & 1 deletion force-app/main/default/classes/MyFirstApexClass.cls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
public with sharing class MyFirstApexClass {
public MyFirstApexClass() {

System.debug('Added the debug');

Check warning

Code scanning / PMD

Calls to System.debug should specify a logging level. Warning

Calls to System.debug should specify a logging level.
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentAsset xmlns="http://soap.sforce.com/2006/04/metadata">
<isVisibleByExternalUsers>false</isVisibleByExternalUsers>
<language>en_US</language>
<masterLabel>One_dreemin_Logo_21</masterLabel>
<originNetwork>PSSupport</originNetwork>
<relationships>
<network>
<access>VIEWER</access>
<name>PSSupport</name>
</network>
<workspace>
<access>INFERRED</access>
<isManagingWorkspace>true</isManagingWorkspace>
<name>sfdc_asset_company_assets</name>
</workspace>
</relationships>
<versions>
<version>
<number>1</number>
<pathOnClient>One dreemin Logo_2-1.png</pathOnClient>
</version>
</versions>
</ContentAsset>
6 changes: 6 additions & 0 deletions force-app/main/default/experiences/PSSupport1.site-meta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<ExperienceBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<label>PSSupport</label>
<type>ChatterNetworkPicasso</type>
<urlPathPrefix>helpportal/s</urlPathPrefix>
</ExperienceBundle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"definitionName" : "service:branding-service",
"id" : "27b3ec9a-5c57-4daf-897f-e4f42d2e0c45",
"label" : "Customer Service",
"type" : "brandingSet",
"values" : {
"ActionColor" : "#a2c315",
"BorderColor" : "#F4F4F4",
"CardBackgroundColor" : "rgba(255, 255, 255, 0)",
"CompanyLogo" : "/file-asset/One_dreemin_Logo_21?v=1",
"DetailTextColor" : "#696969",
"ErrorFontColor" : "#ff9e9e",
"HeaderFonts" : "Montserrat",
"HeaderImage" : "",
"LinkColor" : "#060707",
"LoginBackgroundColor" : "#F4F4F4",
"LoginBackgroundImage" : "../../../../sfsites/picasso/core/external/salesforceIdentity/images/background.jpg?v=1",
"OverlayTextColor" : "#FFFFFF",
"PageBackgroundColor" : "#FFFFFF",
"PrimaryFont" : "Lato",
"TextColor" : "#333",
"TextTransformStyle" : "uppercase",
"_ActionColorDarker" : "#7c9510",
"_ActionColorTrans" : "rgba(162, 195, 21, 0.9)",
"_BackgroundColor1" : "rgb(235, 235, 235)",
"_BackgroundColor2" : "rgb(194, 194, 194)",
"_BackgroundColor3" : "rgb(133, 133, 133)",
"_ColorBackgroundTransparent" : "rgba(255, 255, 255, 0.0)",
"_ColorBackgroundWhite" : "#FFFFFF",
"_DxpPageBackgroundColor" : "#FFFFFF",
"_HoverColor" : "rgba(162, 195, 21, 0.05)",
"_LinkColorDarker" : "#000000",
"_NeutralColor" : "#ecebea",
"_NeutralColor1" : "rgb(217, 215, 213)",
"_NeutralColor2" : "rgb(178, 174, 170)",
"_NeutralColor3" : "rgb(118, 113, 107)",
"_NeutralForegroundColor" : "#000",
"_NeutralForegroundColor1" : "#000",
"_NeutralForegroundColor2" : "#000",
"_NeutralForegroundColor3" : "#fff",
"_OverlayTextColorShadow" : "#000",
"_PrimaryAccentColor1" : "rgb(131, 158, 17)",
"_PrimaryAccentColor2" : "rgb(70, 84, 9)",
"_PrimaryAccentColor3" : "rgb(0, 0, 0)",
"_PrimaryAccentForegroundColor1" : "rgb(255, 255, 255)",
"_PrimaryAccentForegroundColor2" : "rgb(255, 255, 255)",
"_PrimaryAccentForegroundColor3" : "rgb(255, 255, 255)",
"_TextColor1" : "rgb(31, 31, 31)",
"_TextColor2" : "rgb(0, 0, 0)",
"_TextColor3" : "rgb(0, 0, 0)",
"_brandNavigationBarBackgroundColor" : "rgb(115,115,115)",
"_brandNavigationItemBackgroundColorHover" : "rgba(0,0,0,.2)",
"_brandNavigationItemDividerColor" : "rgba(255, 255, 255, 0.2)",
"_desktopFontSizeLarge" : "1rem",
"_desktopFontSizeMedium" : "0.8125rem",
"_desktopFontSizeMediumA" : "0.875rem",
"_desktopFontSizeSmall" : "0.75rem",
"_desktopFontSizeXLarge" : "1.25rem",
"_desktopFontSizeXxLarge" : "1.75rem",
"_desktopLineHeightText" : "1.5",
"_desktopSquareIconMedium" : "2rem",
"brandNavigationBackgroundColor" : "rgb(128,128,128)",
"brandNavigationBarBackgroundColor" : "rgb(115,115,115)",
"brandNavigationColorText" : "#FFFFFF"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"defaultCode" : "en_US",
"defaultLabel" : "English (US)",
"id" : "4adf0a13-1468-4bb0-8f03-b0d18c8d6ea6",
"type" : "languageContainer"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"cmsSettings" : { },
"id" : "40a5d701-69e9-4d23-8aa4-d8e7d7e58ba5",
"label" : "login",
"templateName" : "Login Template",
"type" : "appPage"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"cmsSettings" : { },
"currentThemeId" : "494c6b61-e386-442f-86c3-078a01799e75",
"headMarkup" : null,
"id" : "11523ea2-2e14-4670-beef-bb6307b7e0a4",
"isLockerServiceEnabled" : true,
"isRelaxedCSPLevel" : false,
"label" : "main",
"templateName" : "Service Community Template",
"type" : "appPage"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"id" : "088f2d27-ec36-473a-93b1-af49acb3195f",
"mobilePublisherAppUpdateConfig" : {
"forceAppUpdate" : false,
"enableAppUpdate" : false,
"minVersion" : {
"ios" : {
"version" : "10.0",
"url" : "https://apps.apple.com/us"
},
"android" : {
"version" : "10.1",
"url" : "https://play.google.com/store"
}
}
},
"nativeMobileNavConfig" : {
"showBackButton" : true,
"showHamburgerMenuWithBackButton" : false
},
"nativeTabMenu" : {
"branding" : {
"iconTintColorUnselected" : "#C9C5C5",
"barTintColor" : "#FFFFFF"
},
"menuItems" : [ {
"name" : "Home",
"targetUrl" : "/",
"iconAsset" : "slds-icon:home"
}, {
"name" : "Settings",
"targetUrl" : "/settings/home",
"iconAsset" : "slds-icon:user"
} ]
},
"showHamburgerMenu" : true,
"type" : "nativeConfig"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"forgotPasswordRouteId" : "fcb5e227-081c-4a11-98a5-1ed246b49529",
"isAvailableToGuests" : false,
"isFilteredComponentsView" : false,
"isProgressiveRenderingEnabled" : false,
"loginAppPageId" : "40a5d701-69e9-4d23-8aa4-d8e7d7e58ba5",
"mainAppPageId" : "11523ea2-2e14-4670-beef-bb6307b7e0a4",
"preferredDomain" : "none",
"selfRegistrationRouteId" : "ff4dae90-4ee4-44d3-8401-2916e4c01580",
"type" : "site"
}
Loading
Loading