SalesforceLabs / survey-force

86 stars 61 forks source link

PMD/Prettier and SFDX updates #142

Closed dschach closed 2 years ago

dschach commented 2 years ago
  1. Installed SFDX project files to include PMD, Prettier, and some automation on commit
  2. PMD has been configured with some rules. Install ApexPMD from recommended extensions to view
  3. Some ApexDoc comments have been added, in advance of creating a documentation site for this project. This is a work in progress
  4. LOTS of code has been updated by Prettier - much is whitespace changes.
  5. PMD requested some standardization of method naming and other cosmetic changes
  6. While all tests should have asserts and all those should have custom messages, those PMD violations have been ignored.
  7. LOTS of API version updates
  8. Generally, more readable code (yes, brackets have been moved to same-line. Sorry to offend anyone!)
=== Apex Code Coverage by Class
CLASSES                               PERCENT  UNCOVERED LINES       
────────────────────────────────────  ───────  ──────────────────────
CSUtils                               97%      220,281,332,417,418   
GSurveysController                    86%      32,33,34,35           
SFDCAccessController                  93%      292,293,294,295,296...
SurveyAndQuestionController           82%      17,47,92,93,94...     
GettingStartedController              92%      25,28,29,77,78...     
ViewSurveyController                  86%      39,155,156,157,237... 
SurveySitesUtil                       88%      10,16                 
LexInputFieldCompCtrl                 95%      37,49,116,178         
SurveyManagerController               85%      27,39,40,57,58...     
SFQuestion                            97%      28,83                 
SurveyForceUtil                       90%      25                    
SFDCAccessControlException            100%                           
ViewSurveyControllerWithoutSharing    100%                           
SFMessage                             100%                           
SurveyTestingUtil                     100%                           
ViewShareSurveyComponentController    89%      65,70,74,75,78        
ViewSurveyResultsComponentController  100%                           
SFSurveyQuestionTrigger               100%                           

Some Apex code is still unused outside of tests; that can be in a future update.

jrattanpal commented 2 years ago

@dschach

I pulled in this request. But when I deploy these changes, I get an error.

Not Serializable: Schema.DescribeFieldResult

Can you guess where this error maybe coming from?

This error comes up when I open a survey record (SurveyManagerPage.page)

SurveyForce Error

jrattanpal commented 2 years ago

Here is the apex debug log apex-07L110000120ccHEAQ.log

jrattanpal commented 2 years ago

It's happening in the following code. Trying to figure out what changed.

jrattanpal commented 2 years ago

It's changes in force-app/main/default/classes/LexInputFieldCompCtrl.cls.

If I revert changes to that class then it works

jrattanpal commented 2 years ago

If I change the following public Schema.DescribeFieldResult getFieldDescribe() { if (componentFieldDescribe != null) { return componentFieldDescribe; } Schema.SObjectField sf = getSField(); if (sf != null) { componentFieldDescribe = sf.getDescribe(); return componentFieldDescribe; } else { return null; } }

TO public Schema.DescribeFieldResult getFieldDescribe() { if (componentFieldDescribe != null) { return componentFieldDescribe; } Schema.SObjectField sf = getSField(); if (sf != null) { return sf.getDescribe(); } else { return null; } }

Remove "componentFieldDescribe = sf.getDescribe();" assignment change change with return.

Then it works.

I don't see why it shouldn't but that's where it's failing

dschach commented 2 years ago

Thank you for making the change. This may be blog post-worthy @jrattanpal

jrattanpal commented 2 years ago

@dschach

FYI,

I have published 2.61 version on AppEx with these new changes. I also made some changes in main branch to fix some errors.