|By Lahlali Issam||
|November 26, 2013 11:31 AM EST||
Many Java static analysis tools exist right here, each one focusing on a specific area and each one has its advantages, we can enumerate:
- Pmd which is a static rule-set based Java source code analyzer that identifies potential problems like:
- Possible bugs—Empty try/catch/finally/switch blocks.
- Dead code—Unused local variables, parameters and private methods.
- Empty if/while statements.
- Overcomplicated expressions—Unnecessary if statements, for loops that could be while loops.
- Suboptimal code—Wasteful String/StringBuffer usage.
- FindBugs which looks for bugs in Java code. It uses static analysis to identify hundreds of different potential types of errors in Java programs.
- Checkstyle defines a set of available modules, each of which provides rules checking with a configurable level of strictness (mandatory, optional...). Each rule can raise notifications, warnings, and errors.
Many ways exist to exploit the results of these tools:
- XML format: XML files could be generated from each of these tools, and it can be used to create an HTML report or used by another tool to exploit the analysis result.
- HTML format: HTML report is the prefered way to generate reports and share them between the team, and you can create your custom report by using an xsl stylesheet.
- IDE Plugins: almost all known IDE provides plugins for these tools, which gives the possibility to discover all violations from the source code.
One of the problems with code quality tools is that they tend to overwhelm developers with problems that aren't really problems -- that is, false positives. When false positives occur, developers learn to ignore the output of the tool or abandon it altogether.
And to exploit better their result, it's better to have a way to focus only on what we want and gives to developers a useful view. In this post we will discover another interesting way to exploit better the result of all known java static analysis tools, and query them like a database.
JArchitect and CQLinq
JArchitect is another static analysis tool which complements the other tools, it uses a code query langage based on Linq ( CQLinq) to query the code base like a database.
Until JArchitect 3 you can query only analysis data extracted from JArchitect, however the V4 gives the possibility to import the analysis result from many other static analysis tools and query them with CQLinq.
Let's take as example the source code of the PDT core (the Php plugin for eclipse). and discover how we can exploit the analysis result of these tools from JArchitect.
To begin here are the steps to follows before requesting the analysis result:
- Step1: Analyse the project with PMD, CPD, FindBugs and CheckStyle. And generate the XML files containing the result.
- Step2: Analyze the project with JArchitect.
- Step3: Import all the xml files into JArchitect from the menu "Plugins->Import Plugins Result Files"
Get all issues:
The request to get all issues is very simple, however as you can see it's not very interesting, indeed it's a challenge to exploit a result with 232 725 issues.
To exploit better the result of these tools we can filter it with CQLinq and focus only on what we want.
Request by ruleset
Request by priority
We can also filter by priority:
Most recurrent issues
Classes having most issues
It's very interesting to know the classes which contains many violations
As we can observe CheckStyle report thousand of issues and many of them could be ignored.
The previous query is interesting, but it's not give us exactly the classes with lack of quality, another useful metric to take into account is the NBLinesOfCode, it's normal that a class with many lines of code contains many issues, for that we can modify the previous request to calculate the ratio between the Issues count and the NBLinesofCode.
What's very strange in this result is that the ratio of the 8 first classes is more than 200, in this case we have more than 200 issues by code line.
To explain this behavior let's take a look at some lines of the CompilerAstParser:
The NbLinesOfCode is the number of statements and not the physical lines, and this Class declare many arrays , each one is declared by thousand of physical lines, however each array declaration is considered as one statement.
And as shown before for the most recurrent issues query, the following rule '+' should be on a new line. is violated thousand of times for each array. Maybe it's better to remove these kind of rules from the CheckStyle configuration file.
Most popular methods having issues
When the static analysis tools report the issues, it's useful to locate which the prioritary issues to resolve? specially if it concerns bugs.
It's true that a bug could exist in a specific method, but what interesting to know is how many methods are impacted by the bug, and the popular method are the most used ones and it's better to resolve them quickly.
Using CQLinq we can combine the result of all these tools and also the result of JArchitect to create more elaborated queries, and add these checks to the build process.
Having issues in a project is not bad, we can say that's normal, however we have to check the quality trend of the project. Indeed it's a bad indicator if the number of issues grows after changes and evolutions. /p>
JArchitect provides the Trend Monitoring feature to create trend charts. Trend charts are made of trend metrics values logged over time at analysis time. More than 50 trend metrics are available per default and it is easy to create your own trend metrics.
Let's create a trend metric for the Pmd issues:
And after you can easily create the trend chart to monitor the previous trend metric and add it to the JArchitect dashboard.
With this trend chart we can monitor the evolution of the Pmd issues, and try to understand the reasons when the metric grows over versions.
Customize the JArchitect report
JArchitect make possible to append extra report sections in the HTML report that lists some CQLinq queries. In the CQLinq Query Explorer panel, a particular CQLinq group reported is bordered with an orange rectangle.
You can also add to the report the Pmd trend chart:
And in the HTML report these added sections are accesible from the menu:
And here's the page added in the report for the Pmd CQLinq queries:
JArchitect 4 is now open to other static analysis tools, and you can also plug your customized tool easily as descibed here. This way you can use all the JArchitect features to exploit better the result from the known java static analysis tools.
Internet of @ThingsExpo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 19th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devices - comp...
Sep. 29, 2016 12:45 PM EDT Reads: 5,130
The many IoT deployments around the world are busy integrating smart devices and sensors into their enterprise IT infrastructures. Yet all of this technology – and there are an amazing number of choices – is of no use without the software to gather, communicate, and analyze the new data flows. Without software, there is no IT. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists will look at the protocols that communicate data and the emerging data analy...
Sep. 29, 2016 12:30 PM EDT Reads: 1,743
“We're a global managed hosting provider. Our core customer set is a U.S.-based customer that is looking to go global,” explained Adam Rogers, Managing Director at ANEXIA, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Sep. 29, 2016 12:00 PM EDT Reads: 3,134
According to Forrester Research, every business will become either a digital predator or digital prey by 2020. To avoid demise, organizations must rapidly create new sources of value in their end-to-end customer experiences. True digital predators also must break down information and process silos and extend digital transformation initiatives to empower employees with the digital resources needed to win, serve, and retain customers.
Sep. 29, 2016 12:00 PM EDT Reads: 422
Smart Cities are here to stay, but for their promise to be delivered, the data they produce must not be put in new siloes. In his session at @ThingsExpo, Mathias Herberts, Co-founder and CTO of Cityzen Data, will deep dive into best practices that will ensure a successful smart city journey.
Sep. 29, 2016 11:45 AM EDT Reads: 2,583
Why do your mobile transformations need to happen today? Mobile is the strategy that enterprise transformation centers on to drive customer engagement. In his general session at @ThingsExpo, Roger Woods, Director, Mobile Product & Strategy – Adobe Marketing Cloud, covered key IoT and mobile trends that are forcing mobile transformation, key components of a solid mobile strategy and explored how brands are effectively driving mobile change throughout the enterprise.
Sep. 29, 2016 11:30 AM EDT Reads: 2,146
DevOps at Cloud Expo, taking place Nov 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 19th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait for long dev...
Sep. 29, 2016 11:00 AM EDT Reads: 3,511
Cloud computing is being adopted in one form or another by 94% of enterprises today. Tens of billions of new devices are being connected to The Internet of Things. And Big Data is driving this bus. An exponential increase is expected in the amount of information being processed, managed, analyzed, and acted upon by enterprise IT. This amazing is not part of some distant future - it is happening today. One report shows a 650% increase in enterprise data by 2020. Other estimates are even higher....
Sep. 29, 2016 11:00 AM EDT Reads: 4,164
The Jevons Paradox suggests that when technological advances increase efficiency of a resource, it results in an overall increase in consumption. Writing on the increased use of coal as a result of technological improvements, 19th-century economist William Stanley Jevons found that these improvements led to the development of new ways to utilize coal. In his session at 19th Cloud Expo, Mark Thiele, Chief Strategy Officer for Apcera, will compare the Jevons Paradox to modern-day enterprise IT, e...
Sep. 29, 2016 11:00 AM EDT Reads: 2,405
What happens when the different parts of a vehicle become smarter than the vehicle itself? As we move toward the era of smart everything, hundreds of entities in a vehicle that communicate with each other, the vehicle and external systems create a need for identity orchestration so that all entities work as a conglomerate. Much like an orchestra without a conductor, without the ability to secure, control, and connect the link between a vehicle’s head unit, devices, and systems and to manage the ...
Sep. 29, 2016 11:00 AM EDT Reads: 300
In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lea...
Sep. 29, 2016 11:00 AM EDT Reads: 396
What are the new priorities for the connected business? First: businesses need to think differently about the types of connections they will need to make – these span well beyond the traditional app to app into more modern forms of integration including SaaS integrations, mobile integrations, APIs, device integration and Big Data integration. It’s important these are unified together vs. doing them all piecemeal. Second, these types of connections need to be simple to design, adapt and configure...
Sep. 29, 2016 10:45 AM EDT Reads: 450
In his general session at 18th Cloud Expo, Lee Atchison, Principal Cloud Architect and Advocate at New Relic, discussed cloud as a ‘better data center’ and how it adds new capacity (faster) and improves application availability (redundancy). The cloud is a ‘Dynamic Tool for Dynamic Apps’ and resource allocation is an integral part of your application architecture, so use only the resources you need and allocate /de-allocate resources on the fly.
Sep. 29, 2016 10:30 AM EDT Reads: 2,897
19th Cloud Expo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterpri...
Sep. 29, 2016 10:30 AM EDT Reads: 4,443
SYS-CON Events announced today that CDS Global Cloud, an Infrastructure as a Service provider, will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. CDS Global Cloud is an IaaS (Infrastructure as a Service) provider specializing in solutions for e-commerce, internet gaming, online education and other internet applications. With a growing number of data centers and network points around the world, ...
Sep. 29, 2016 10:30 AM EDT Reads: 2,980
Information technology is an industry that has always experienced change, and the dramatic change sweeping across the industry today could not be truthfully described as the first time we've seen such widespread change impacting customer investments. However, the rate of the change, and the potential outcomes from today's digital transformation has the distinct potential to separate the industry into two camps: Organizations that see the change coming, embrace it, and successful leverage it; and...
Sep. 29, 2016 10:30 AM EDT Reads: 1,244
Major trends and emerging technologies – from virtual reality and IoT, to Big Data and algorithms – are helping organizations innovate in the digital era. However, to create real business value, IT must think beyond the ‘what’ of digital transformation to the ‘how’ to harness emerging trends, innovation and disruption. Architecture is the key that underpins and ties all these efforts together. In the digital age, it’s important to invest in architecture, extend the enterprise footprint to the cl...
Sep. 29, 2016 10:15 AM EDT Reads: 616
There are several IoTs: the Industrial Internet, Consumer Wearables, Wearables and Healthcare, Supply Chains, and the movement toward Smart Grids, Cities, Regions, and Nations. There are competing communications standards every step of the way, a bewildering array of sensors and devices, and an entire world of competing data analytics platforms. To some this appears to be chaos. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, Bradley Holt, Developer Advocate a...
Sep. 29, 2016 10:15 AM EDT Reads: 2,390
SYS-CON Events announced today that LeaseWeb USA, a cloud Infrastructure-as-a-Service (IaaS) provider, will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. LeaseWeb is one of the world's largest hosting brands. The company helps customers define, develop and deploy IT infrastructure tailored to their exact business needs, by combining various kinds cloud solutions.
Sep. 29, 2016 10:15 AM EDT Reads: 3,300
WebRTC is bringing significant change to the communications landscape that will bridge the worlds of web and telephony, making the Internet the new standard for communications. Cloud9 took the road less traveled and used WebRTC to create a downloadable enterprise-grade communications platform that is changing the communication dynamic in the financial sector. In his session at @ThingsExpo, Leo Papadopoulos, CTO of Cloud9, discussed the importance of WebRTC and how it enables companies to focus...
Sep. 29, 2016 10:00 AM EDT Reads: 2,318