Tag: tools

Entries for tag "tools", ordered from most recent. Entry count: 74.

Warning! Some information on this page is older than 5 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Pages: > 1 2 3 4 ... 10 >

# CppDepend 4 Pro for Free

Jan 2014

It looks that they've just released a new major version of CppDepend - great static code analysis tool for C++. What's New in CppDepend 4 page lists several improvements. What is more important though is that they've decided to give away Pro license for free to open source C/C++ contributors. They say:

To apply for this free license, Please make sure that you meet the following criteria:

I think it's worth trying to apply for that. See also my review of CppDepend.

Comments | #tools #c++ Share

# CppDepend

Sep 2012

Recently I've played a little bit with CppDepend - a commercial static code analysis tool for C++. Windows and Linux versions are available and you can download 14-days trial version. You can find lots of information about the program on their website, including screenshots, sample reports, and cases studies of Ogre3D and Irrlicht game engines. Here is my brief review.

At first glance, program looks like typical commercial Windows application full of colourful icons, popup windows, hints and tips everywhere. They have their own, non-standard looking GUI, but it clearly resembles the one from Visual Studio, including docking side panels, error list at the bottom etc. Skin can be changed to make the program look like GUI from different versions of Microsoft Office, among others. Even the HTML report is full of JavaScript and knows better than you when you want to open a link in new window (that is, in most cases). But after getting used to it I think everything is designed reasonably and makes this powerful application really easy to use.

First thing you have to do is to create a CppDepend project. You can add Visual Studio solutions to it and set parameters about what reports you want. Alternatively, if you don't have one beacuse e.g. you use makefiles, you can use separate tool - ProjectMaker - to manually create and save some virtual .sl "solution" that enlists source files and directories to analyze.

Then the program analyzes your code (internally using Clang) and builds a database about it. It generates report in HTML format, as well as allows browsing gathered data interactively inside the program (or inside Visual Studio if you install appropriate AddIn). Here you can see how it looks like for some of my code, combined The Final Quest 7 and CommonLib. First of all, you can browse tree of projects, namespaces, classes and methods:

A HTML raport is generated with the list of found issues:

You can visualize different kinds of relationships like inheritance or just using one type by another as a graph:

Another way to visualize dependencies is matrix:

Yet another view mode is treemap. Here I displayed methods (grouped in classes and modules) where size of a method is dependent on number of lines of code.

You can perform simple search and sorting of projects, namespaces, types, methods and files by name, size and different other metrics. Matched items are highlighted on the treemap.

Finally, you can issue complex queries using CQLinq - a query language based on C# LINQ syntax. Embedded query editor is available with syntax highlighting, autocompletion and immediate query output as you type.

So what kinds of data does the program gather from your code? A lot of. Even such simple thing as number of lines of code is calculated intelligently. Instead of text-based, these are logical LOC, which count sequence points in code, so they are independent of coding style, like braces placement or spanning function call on several lines of code.

I didn't mess with code metrics before, so it was interesting for me to read what does it mean for a piece of code to be "stable" or "abstract". It turns out that the code is stable if its types are used by a lot of types of third-party modules. On the other hand, code is abstract when it contains a lot of abstract classes and interfaces. Code that is stable but not abstract can be painful to modify. Code that is not stable and very abstract is useless. Sounds like an interesting idea :)

Another interesting metric is Cyclomatic Complexity. It is basically a number of decision that can be taken in a function, that is number of: if, while, for, case, default, continue, goto, catch etc. Lack of Cohesion Of Methods (LCOM) is yet another metric. It can indicate quality of a class. It is low when almost every methods in the class uses every field, which is good. It is high when, for example, every method uses only one field (like when class has only getters and setters), which is bad.

Based on these metrics (and many others) and some predefined rules, a list of issues found in the code is enlisted in the report. Some of them are very valuable, some not so much. For example, code matching the rule "Constructor should not call a virtual methods" is obviosly a bug or at least a bad practice. But the rule "Fields should be declared as private" seems a little too restrictive, especially as it matches also globals like const float PI = 3.14.

Generally, it feels great to have analysis based on both physical aspect (like directory structures, source files, comments) and logical aspect of the code (like class inheritance, public versus private, number of nested loops). It's also great that the program analyzes code on all levels, from whole solution depending on external (and possibly unknown) code like Windows.h, through namespaces, classes and methods, down until analyzing code inside functions, counting number of conditions, loops, local variables and analyzing which classes and methods are used by which.

Static code analysis tool like CppDepend is not one of the tools necessary for programming, like editor, compiler or debugger. But I believe it can be useful in at least following applications:

When thinking about a conclusion, I have this thought based on some blogs posts I've read recently (here is the first one, unfortunately I can't find the other one right now) that there is a spectrum of different types of programmers. On one side, there are these very "good", rockstar programmers who are not as good at teamwork and instead of solving real practical problems, they play around with code, talk about theory (whether algorithms or language standard) and write so sophisticated code (e.g. with elaborate C++ template tricks) that it is hard to read and maintain for others. They don't bother to give their variables some meaningful names or split their code into clear modules and classes. On the other side of the spectrum there is the growing number of bad programmers who graduate computer science because they were told to do so (with a promise for good money, lots of jobs or anything) and have no real talent, passion or even basic willingness to learn this profession. They only glue their code using ready frameworks, design patterns and code found on Google using Ctrl+C Ctrl+V. I can see clear relationship between this spectrum and the seriousness with which we take reports about code metrics like these genetared by CppDepend. I also believe that in both cases the best approach lies somewhere in the middle.

Appendix: Clang Rocks! is an interesting article by Issam Lahlali, CppDepend lead developer, that explains how they use Clang frontend to analyze C++ code in their product.

Update: CppDepend v2017 has been released recently, adding many great features, including the following:

Comments | #tools #c++ Share

# Visual Merge Tool (P4Merge)

Sep 2012

Perforce (or P4 for short) is a commercial version control system used in many companies instead of free CVS, SVN, Mercurial or Git. It has its pros and cons, but the included diff/merge tool is definitely its good point. It's actually the best tool of this kind I've ever seen on Windows, better than free TortoiseMerge, DiffMerge or KDiff3. It turns out that this tool is also free!

To grab it, go to Perforce Downloads and download appropriate (32-bit or 64-bit) version of the P4V: Visual Client. Then install it, but from the installation components leave only "Visual Merge Tool (P4Merge)". Now you have this great, free tool in your system.

To setup it as diff and merge tool in TortoiseGit (TortoiseSVN and others are similar I think), follow instructions from article Using P4Merge with TortoiseGit. Basically, enter TortoiseGit Settings and there:

Comments | #tools #version control Share

# jEdit Doesn't Start

Oct 2011

jEdit is a free, multi-platform and my favorite text editor intended for programmers. Some time ago I encountered a problem with it, which repeated again today. So in case you also use this editor or found this post by searching Google, here is the solution:

Problem: jEdit (on Windows) doesn't start. Process is created and exists in memory, but it does nothing and shows no windows, so the only thing you can do is terminating it.

Solution: Terminate the jEdit process and the process of Java virtual machine, then browse to your user directory (like "C:\Users\Adam Sawicki" on my Windows 7) and delete the following small file in a sudirectory: ".jedit\server". After that you will be able to successfully start jEdit.

Comments | #java #tools #windows Share

# Hotkey for Macro Inserting Text

Aug 2011

I recently code in C - an ancient language with no support for namespaces. To code a bigger system and not create name conflicts, prefixes for all public identifiers must be used. But they not only make the code less readable, but also take lots of time to type. I thought that at least the second issue can be minimized by setting up some macro that would insert predefined text (like "rendering_"), whenever I press a hotkey button (like Pause/Break).

I couldn't find such feature in my Visual C++ 2010 Express, so I decided to look for some general tool for Windows that can trigger a script when a hotkey is pressed. I found AutoHotkey - a free application with its own scripting language that claims to be successor of AutoIt, which I used some time ago. After reading some documentation, I coded following script:

SetKeyDelay -1
send rendering_

SetKeyDelay -1

If you have AutoHotkey installed, just save this code to a file, give it "ahk" extension and double-click to run it. Program will create a system tray icon for this script indicating that it's running in the background. From now on you can just press Pause key to insert text "rendering_" to whatever input control you are focused, or Shift+Pause to insert "RENDERING_". It really speeds up coding in C :)

Comments | #windows #tools #c Share

# Static C++ Code Analysis with PVS-Studio

Mar 2011

By the courtesy of its authors, I have a chance to evaluate PVS-Studio - a static code analyzer for C, C++ and C++0x. This commercial application is installed as a plugin in Visual Studio 2005/2008/2010. Fortunately I have Visual Studio 2008 Professional at home so I could try it with the code of my personal projects. PVS-Studio differs from other tools of this kind, like free Cppcheck, by finding three types of errors or warnings: general, related to OpenMP and 64-bit portability issues.

After opening my solution in Visual Studio, I choose a command from the special menu to analyze all the code.

A progressbar appears while PVS-Studio does the computations, utilizing almost 100% of all 4 CPU cores. Finally, a dockable panel appears with a list of found issues.

The general category warns about exact float comparison with == and stuff like that. It managed to find few places where I forgot the "&" character while passing a vector as const refefence parameter, rightly telling that it will cause "decreased performance". But its greatest find in my CommonLib library code was this unbelievable bug:

Some messages look funny. Should I code some general, abstract, portable, object-oriented, Alexandrescu-style template-based solution here just to avoid copying some code into several similar instructions? :)

I didn't check how the OpenMP validation works because I don't currently use this extension. As for 64-bit compatibility issues, I have lots of them - just because my code is not prepared to be compiled as 64-bit. PVS-Studio seem to do a good job pointing to places where fixed-length 32-bit integers are mixed with pointers, array indexing etc.

Overall, PVS-Studio looks like a good tool for C++ programmers who care about the quality of their code. Finding issues related to OpenMP and 64-bit compatibility can be something of a great value, if only you need such features.

Too bad that PVS-Studio, opposite to Cppcheck, is a Visual Studio plugin, not a standalone application, so it obviously requires you to have a commercial MSVS version and do not work with Express edition. But this is understandable - if you need OpenMP or 64-bit, you probably already use Visual Studio Professional or higher.

PVS-Studio analyzes C, C++ and C++0x. It doesn't work with C++/CLI language, but that's not a big flaw too. I use C++/CLI at work, but I can see it's quite unpopular, niche language. Its compilation or analysis would also be very difficult because it mixes all features from both native C++ and .NET. Even Microsoft didn't find resources to implement IntelliSense for C++/CLI in Visual Studio 2010.

Comments | #tools #c++ #software engineering #visual studio #pvs-studio Share

# Naprawiacz nazw plików - My Little Tool

Feb 2011

Here I publish a small C# program that I developed for some specific needs of my father, but some of you may also find useful. It recursively searches selected directory for files and subdirectiores which names are too long or contain some non-ANSI characters, especially Russian cyryclic or Polish diacritic letters. It then presents the list and lets you manually rename or delete selected items, as well as automatically rename all selected items to convert these special letters to their English transcription.

This program can be useful if you collect some ebooks or other documents and need to store, pack or catalog these files in some way that doesn't like long names or nonstandard characters. The whole GUI is in Polish. The program requires .NET Framework 4. Source code in C# is attached. I think this code can be good entry point to write other similar programs that look for files and directories that meet some specific criteria.

Naprawiacz_nazw_plikow_bin.zip (EXE file)
Naprawiacz_nazw_plikow_src.zip (C# source code)

Now the Polish version:

Chciałbym opublikować mały program w C#, który napisałem dla specyficznych potrzeb mojego taty, ale może okazać się przydatny także innym. Program rekurencyjnie przeszukuje wskazany katalog w poszukiwaniu plików i podkatalogów, których nazwy są zbyt długie lub zawierają znaki spoza zakresu ANSI, szczególnie cyrylicę i polskie znaki diakrytyczne. Następnie prezentuje listę, na której można ręcznie zmieniać nazwy i usuwać wybrane elementy, a także automatycznie zmienić nazwy wszystkich zaznaczonych elementów konwertując te zestawy liter na ich transkrypcje po angielsku.

Ten program może się przydać, jeśli zbierasz ebooki czy inne dokumenty, a chcesz je zapisywać, pakować czy katalogować za pomocą takich programów, które nie radzą sobie ze zbyt długimi nazwami albo niestandardowymi znakami. Interfejs programu jest w języku polskim. Program wymaga zainstalowanego .NET Framework 4. Do archiwum dołączam kod źródłowy w C#. Myślę, że ten kod może być dobrym punktem wyjścia do pisania innych podobnych programów, które wyszukują pliki i katalogi spełniające podane kryteria.

Comments | #.net #tools Share

# Static Code Analysis with Cppcheck

Oct 2010

Yesterday I've tried Cppcheck - an open source tool for static C++ code analysis. That was my first practical experience with this kind of tools and I like it quite a lot. Static code analysis is the analysis performed without actually executing a program. Source code is checked against some rules to find common bugs and mistakes.

I expected to see a program that must be given paths to my IDE and all libraries I use in some configuration file before I could execute some console application with poper command line parameters and get some crypic report as the result. All in all, that's the way many programmer's tools work, especially open source ones and specially these for C or C++ languages. But here it was not the case. Cppcheck is a GUI program in which I could just click Check / Directory and read the results of the analysis while the processing was still being done in the background.

Developers of Cppcheck state on their website that "The goal is no false positives.". Apparently they haven't high-performance gamedev code in mind :) The program reported many warnings like "Member variable not initialzed in the constructor 'VEC3::x'". Generally speaking it could be dangerous, but if I want my 3D vector structure to behave like a built-in type and work as fast as possible, leaving its fields uninitialized in the default constructor is exactly what should be done.

But Cppcheck also found some real mistakes in my code, like passing "const VEC3 lhs" parameter (where I forgot about the reference "&") or some local variables that were assigned but never used. So overall I think static code analysis could be of some help to a C++ programmer.

Comments | #c++ #tools Share

Pages: > 1 2 3 4 ... 10 >

[Download] [Dropbox] [pub] [Mirror] [Privacy policy]
Copyright © 2004-2022