Style Checker Tools
Semantic Designs builds style/coding-standards checkings tools based on the DMS Software Reengineering Toolkit, which provides precise language parsing and code analysis capabilities.
There are many good reasons for adhering to a sound, regular style (or selected standards) of programming in large systems. Developers spend a significant fraction (up to 50%) of their time just looking at source code. A good, consistent style regarding naming conventions, presence and locations of comments, and standard ways of coding common idioms would make programmers more productive by enabling them to avoid guesswork and to be sure where to look and what to expect. Moreover, most programming languages have constructs which, if used improperly (or at all) tend to result in code that is fragile and difficult to maintain or even dangerous. Enforcing certain standards can help avoid entire classes of errors. While some developers have personal, effective styles that they use carefully, most do not, and many maintenance programmers are forced to work with code that has an unfamiliar style, or worse, style damaged by the inconsistent or ineffective practice of many sets of hands over time.
Moreover, software evolution can take a toll on the maintainability of a system. The complexity of a large system can hide that data declarations have become unused and that sections of procedural code have become unreachable, or that modernization has introduced new idioms that are not universally observed within the system. Language evolution and plans for future evolution can introduce pending or actual reserved words that conflict with user identifiers in legacy systems. Best practices in program structure can change over time, and internal conventions can be developed which suggest the need or opportunity for sweeping software change in style.
Many organizations have preferred programming styles that they would like their programmers to consistently observe, with some elements that enforce good programming practice and others that embody coding conventions whose virtue is simple regularity and predictability. Tool support can help the organizations maintain their code in compliance with these policies. In daily practice, individual programmers may stray from these guidelines, or code may be imported that was not developed with the organization's guidelines in mind. A tool that can identify non-compliant code is useful in guiding programmers toward satisfactory, consistently observed programming style.
The Semantic Designs Style Checker tools process source code and diagnose violations of predefined sets of language-specific and customer-specific style rules. A report is produced for each violating code fragment, specifying which style rule was broken, providing an explanation, and locating the offending code fragment by source file and line position. A programmer may use this set of complaints to modify his code to bring into conformance with style guidelines.
For some style violations, the tool can automatically modify the code to fix the problem or make a specific suggestion of what modification should be made. It can also warn when making such a change is potentially dangerous as requires extra care, for example when modifying shared infrastructure code in a system.
Style checker tools are a popular idea and people keep trying to build them. Usually such tools are built using regular expressions to parse source code. Regular expressions are useful for scanning many kinds of strings with simple structure, but cannot handle the nested structures typical of a program. This Stack Overflow answer hints at how badly regexes fail for parsing. What is needed for a good style checker foundation is a tool that interpret the source code provided in a deep semantic fashion. Regexes cannot do this well. Regex based style checkers can only do weak checks, and may produce many time-wasting false positives, which disincentivizes engineers to use such tools.
SD's StyleChecker tools work in conjunction with
On certain development platforms, the Style Checkers come packaged with a graphical user interface that integrates configuration support, source file selection, source file editing, tool invocation and re-invocation, diagnostic browsing, and automatic application of suggested fixes. The tool can be thus integrated with development environment familiar to the software system's development engineers.
- Processes an arbitrary number of files in a given project
- Supports user choice of style checking rules to be applied
- Understands source language syntax and semantics precisely
- Produces detailed text and XML output and a collated executive summary of results
- Applies style rules above and beyond compiler requirements, including rules requiring flow analysis, for example to locate dead code or unused data declarations
- Checks commenting conventions, proper use of structured statements
- Implements language-specific style rules that can be customer-specific on request
- Accurately locates style rule violations
- Suggests specific code modifications
- Issues warnings on potentially dangerous modifications, for example on shared infrastructure files
- Runs as a standalone utility or on some platforms under a graphical user interface
- Supports browsing of diagnostics and automates application of fixes in its graphical user interface
- Tool not dependent on any particular compiler
- Works with arbitrary subsets of source code base
Available for the Following LanguagesDownload an evaluation version
Is your language not listed? Does it run in an unusual environment? Do you have some custom style rules which you would like to enforce? SD can implement a Style Checker tool for you! These tools are based on DMS, and inherit DMS's language agility and scalability.