SemmleCode
Encyclopedia
SemmleCode is a tool for improving the quality of computer software. It can be used to find programming bug patterns, to compute software metrics, and to enforce coding conventions
Coding conventions
Coding conventions are a set of guidelines for a specific programming language that recommend programming style, practices and methods for each aspect of a piece program written in this language...

. All these tasks can be formulated as queries in an object-oriented query language
Query language
Query languages are computer languages used to make queries into databases and information systems.Broadly, query languages can be classified according to whether they are database query languages or information retrieval query languages...

 named .QL
.QL
.QL is an object-oriented query language used to retrieve data from relational database management systems. It is reminiscent of the standard query language SQL and the object-oriented programming language Java. .QL is an object-oriented variant of a logic programming language known in the...

.

Academic

SemmleCode builds on a long tradition of academic research on querying the source of software programs. The first such system was Linton's Omega system, where queries were phrased in QUEL, a derivative of SQL. QUEL did not allow for recursion
Recursion
Recursion is the process of repeating items in a self-similar way. For instance, when the surfaces of two mirrors are exactly parallel with each other the nested images that occur are a form of infinite recursion. The term has a variety of meanings specific to a variety of disciplines ranging from...

 in queries, making it difficult to inspect hierarchical program structures such as the call graph
Call graph
A call graph is a directed graph that represents calling relationships between subroutines in a computer program. Specifically, each node represents a procedure and each edge indicates that procedure f calls procedure g...

. The next significant development was therefore the use of logic programming
Logic programming
Logic programming is, in its broadest sense, the use of mathematical logic for computer programming. In this view of logic programming, which can be traced at least as far back as John McCarthy's [1958] advice-taker proposal, logic is used as a purely declarative representation language, and a...

, which does allow such recursive queries, in the XL C++ Browser. The disadvantage of using a full logic programming language is however that it is very difficult to attain acceptable efficiency. The CodeQuest system, developed at the University of Oxford
University of Oxford
The University of Oxford is a university located in Oxford, United Kingdom. It is the second-oldest surviving university in the world and the oldest in the English-speaking world. Although its exact date of foundation is unclear, there is evidence of teaching as far back as 1096...

, was the first to exploit the observation that Datalog
Datalog
Datalog is a query and rule language for deductive databases that syntactically is a subset of Prolog. Its origins date back to the beginning of logic programming, but it became prominent as a separate area around 1977 when Hervé Gallaire and Jack Minker organized a workshop on logic and databases...

, a very restrictive version of logic programming, is in the sweet spot between expressive power and efficiency. The .QL query language
.QL
.QL is an object-oriented query language used to retrieve data from relational database management systems. It is reminiscent of the standard query language SQL and the object-oriented programming language Java. .QL is an object-oriented variant of a logic programming language known in the...

 is an object-oriented version of Datalog.

Industrial

The early research works on querying the source of software programs spun off a number of industrial applications. In particular it became the cornerstone of systems for application intelligence (data mining
Data mining
Data mining , a relatively young and interdisciplinary field of computer science is the process of discovering new patterns from large data sets involving methods at the intersection of artificial intelligence, machine learning, statistics and database systems...

 on the source of software systems) and software renovation. In 2007, Paris-based CAST is one of the market leaders in that area, and other significant players include BluePhoenix in Herzliya, Israel. SemmleCode differs from these systems in its use of an object-oriented query language, which allows programmers to easily formulate new queries that are particular to their own project.

A full account of the academic and industrial developments leading up to the creation of SemmleCode can be found in the paper by Hajiyev cited below.

Sample query in .QL

To illustrate the use of .QL, consider the well-known rule in object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 that public fields should be declared final. To find violations of that rule, we should search for fields that are public but not final. In .QL, that requirement is expressed as follows:
from Field f
where f.hasModifier("public")
and
not(f.hasModifier("final"))
select f.getDeclaringType.getPackage,
f.getDeclaringType,
f
Here we select not only the offending field f, but also the package and type in which its declaration occurs.

Integration with development environments

SemmleCode provides a user interface
User interface
The user interface, in the industrial design field of human–machine interaction, is the space where interaction between humans and machines occurs. The goal of interaction between a human and a machine at the user interface is effective operation and control of the machine, and feedback from the...

 via the Eclipse IDE to query Java code (both source code and bytecode) as well as XML files, and to edit .QL queries. This is however but one application of the technology that underlies it: .QL can be used to query any other type of complex data.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK