Sunday, November 28, 2010

Hello, CFWarning!

Since this is my first post I should probably introduce myself. As the title of my blog suggests, my name is Luke. I am primarily a ColdFusion developer, but I play with a lot of other languages and technologies as well (hopefully there will be more posts to support this statement!). That's enough for now, I want to talk about something more interesting.

The motivation for starting this blog was to share a project that I have been working on for a while now. The project is called CFWarning (you can probably already tell that I am pretty creative when it comes to naming things), and is an Eclipse plugin. It is hosted on github. The project began as a personal goal to learn how to create an Eclipse plugin, and to create something I found useful.

I chose to create a view that would inspect my code and show me warnings as I wrote the code. To achieve this I had to write a ColdFusion parser of sorts. Now, I am not an expert on parsers and I am sure that there are many things that I could have done better. However, my main objective was to create a useful Eclipse plugin, so I didn't want to focus on how to create the perfect parser. So, I wrote my own parser for tag components and began to create a view to show warnings.

Scoping seemed like the logical place to start. So, I updated the view to display all the functions in the currently open component that have unscoped variables. The view updates the warnings when the file gains focus or is saved. I would like mention that there is already a project out there that scans components for scoping issues called varScoper. If you want to scan a large number of components at once, or don't have an Eclipse based IDE, I would really recommend this tool. It can also be used as a ColdFusion Builder extension.

The second thing that I was able to do easily was to warn about possible debug code. I like to use cfdump and cfabort a lot for debugging, and may be guilty of occasionally committing before I remove the debugging code. So, I added warnings to my view that display whenever cfdump or cfabort are used in a component.

Below is what the view looks like. It's nothing fancy but gets the job done right now. The first line indicates how many functions were found in the component and how many warnings were found. After that it begins to show the warnings. Each line starts with the line number. Warnings are grouped by the function that they are found in, and each line gives a short description of the warning. The warning lines will take you to the line in the file where the warning exists when double clicked.



To install the plugin you will need to grab the jar file download from github and place it in the 'dropins' directory of your Eclipse install. Then restart or open Eclipse and choose the CFWarning view. Right now the plugin only works on tag components for the functionality that I discussed above, and was designed for ColdFusion 9. It isn't perfect and already has some known issues, but I felt it was at a point that it could be shared. Download it, give it a try and let me know what you think. I plan to continue updating the plugin for other features (see the README on github for some of the features I want to add), so if you have any ideas for future warnings let me know.

2 comments:

  1. Thats a cool idea for a plugin.

    Perhaps some color or icons for the warnings? And can you change the look of the CFWarning header when there is a problem?

    ReplyDelete
  2. Yeah, the view definitely needs some work. My plan right now would be to make it a table with icons like the problems view.

    ReplyDelete