+ Start a Discussion

VSCode Does Not Validate Apex Code

Hello All,
    I am working with VS Code and I see it is not validating Apex errors. For instance the below code, in VS Code does not show any errors where as it should be showing 2. User-added image

VS Code only shows issues when I miss a semi-colon or a paranthesis. I have Salesforce CLI Integration, Salesforce Extension Pack, Apex extension packs installed. 
Even with these I do not get prompted for errors. I have to copy my code from VS Code and put it in Developer Console to figure out what is wrong. It becomes counter productive.

The same code when I use it in Dev console, shows the required errors
User-added image

What am I missing here in the VS Code Configuration?

Team NubesEliteTeam NubesElite
Hi Gautam,
Please follow below mentioned steps

Install CLI –
Install VSCode –

Install Extension –
Salesforce Extension Pack
Lightning Web Co mponents
Salesforce CLI Integration

Open Terminal (View > Terminal)
Control + Shift + p to open command pallet instead of typing in

Execute the following command to create new project –
sfdx force:project:create n "Project Name"
Note: Replace "Project Name" with the name you want
Note: Control + Shift + p and select "SFDX: Create Project with Manifest" to see all the sfdx commands in the pallet.

Setting Instanceurl -
sfdx force:config:set instanceUrl=https://login.salesforce.com
Note: for sandbox: instanceUrl=https://test.salesforce.com
Note: "sfdx-project.json" file can be modified if you want to execute from pallet (select "SFDX: Authorize an Org")

Execute the following command to login
sfdx force:auth:web:login sfdx force:auth:web:login --a OrgAliasNamea OrgAliasName
Example: sfdx force:auth:web:login -a Batch61 -d
Note: -d if you want to keep the org as default
Note: to verify that already if the org is authenticated use "sfdx force:org:list" command, It will show list of authorized orgs. (-u means: username or alias for the target org; overrides default target org)
Note: opening a specific org with the alias name: sfdx force:org:open -u Batch62
Note: if you want to switch from one org to another org use: SFDX: Set a Default Org in the Pallet.

Execute to get the help of specific command –
sfdx force:auth:web:login sfdx force:auth:web:login --hh

Create new apex class –
sfdx force:apex:class:create sfdx force:apex:class:create --n ApexClassName n ApexClassName --d forced force--app/main/default/classes/app/main/default/classes/
Note: -n is for the name, -d for the directory to store the apex class

To retrieve only apex classes -
sfdx force:source:retrieve sfdx force:source:retrieve --m ApexClassm ApexClass
Note: for the more commands -

To retrieve the components from the server -
sfdx force:ssfdx force:source:retrieve ource:retrieve ----manifest manifestmanifest manifest\\package.xmlpackage.xml
Note: open the package.xml which can find in manifest and right click > select "SFDX: Retrieve This Source from Org"

Directly retrieve or deploy the components by opening a specific Apex Class/ Apex Trigger so on or execute the command as below -
sfdx force:source:deploy
sfdx force:source:deploy ----json json ----loglevel fatal loglevel fatal ----sourcepath forcesourcepath force--appapp\\mainmain\\defaultdefault\\classesclasses\\Calculations.clsCalculations.cls

Thank You

Developement | Training | Consulting

Please Mark this assolution if your problem resolved.