DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Frameworks
  4. Free Static Code Analysis with Eclipse

Free Static Code Analysis with Eclipse

Erich Styger user avatar by
Erich Styger
·
Jan. 10, 13 · Interview
Like (0)
Save
Tweet
Share
11.85K Views

Join the DZone community and get the full member experience.

Join For Free


i know for myself: the earlier i’m able to fix a bug, the better. so i’m always grateful for things which help me to find issues in my sources as early in the development process as possible. eclipse and codewarrior already help me to find syntax errors in my code while i’m typing:

eclipse highlighting syntax error

eclipse highlighting syntax error

with the built-in syntax checker of eclipse, this helps me many times to get things right without the need to build my code with the compiler. but when i’m able to compile successfully my code, this does not mean it is without bugs. it would be good to catch as many errors *before* downloading and running it on the target.

i have presented a while ago pc-lint : but this does not come free of charge. the good news is that the new eclipse version in codewarroir for mcu10.3 has static code analyser built-in: code name “codan” : not as powerful as pc-lint, but good enough as a little helper.

c/c++ code analysis

the static c/c++ code analysis is available if i select the project and use the context menu:

run c/c++ code analysis

run c/c++ code analysis

but when i run this, nothing seems to happen?

enabling code analysis

the reason is that codewarrior has it disabled by default in a new workspace. it is enabled/disabled for each project. what i recommend is to enable it on the workspace level. using the menu window > preferences and filter for ‘code’ shows the setting:

code analysis options in preferences

code analysis options in preferences

usually i enable all the ‘potential programming problems’:

enabled code analysis settings

enabled code analysis settings

the cool thing is: now it parses my sources in the background for problems:

problem view with code analysis report

problem view with code analysis report

additionally it flags the problem place in the source view:

problem in source view

problem in source view

at any time, code analysis is run with the context menu on the project folder.

customizing code analysis

the analysis is customized using the ‘ customize selected.. ‘ button:

customize selected

customize selected

i can configure the behaviour, such as if things are worth an error or are just a warning:

preferences for problem checking

preferences for problem checking

for example i can specify inclusion or exclusion pattern/files for each message:

inclusion and exclusion patterns

inclusion and exclusion patterns

:?: i have not found a way to configure/disable messages directly in the source files. that’s something i really like with pc-lint, but i’m not able to do with the eclipse c/c++ code analysis?

summary

i expect the features and functionality of the c/c++ code analysis to grow and extend over time in eclipse. right now it is able to catch not that many problems, and some are rather basic. but still: it helps to get my code right the first time. there are sometimes bogus messages, but then i can disable the messages or add that file to the ‘exclusion’ list. and even a small little helper adds to the benefits of eclipse.

happy analysing :)

Eclipse

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Secure Your CI/CD Pipeline
  • How To Check Docker Images for Vulnerabilities
  • Event Driven 2.0
  • Stream Processing vs. Batch Processing: What to Know

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: