Mostrando las entradas con la etiqueta sonar. Mostrar todas las entradas
Mostrando las entradas con la etiqueta sonar. Mostrar todas las entradas

jueves, 18 de noviembre de 2010

Sonar 2.4 disponible

Ya fue liberada la versión 2.4 de Sonar, la excelente herramienta open source para análisis de código fuente. Entre las mejoras están soporte para actualización de plugins desde la misma herramienta (Update Center) y un nuevo diseño del dashboard basado en widgets el cual permite seleccionar el layout y los widgets a mostrar. Para ver la lista completa de cambios y descargar la versión deben ir a la siguiente pagina.

jueves, 14 de octubre de 2010

Sonar 2.3 disponible

Ya esta disponible la versión 2.3 de Sonar. Para descargarlo usen este enlace. Es bueno que revisen las notas de actualización asi como la matriz de compatibilidad de los plugins.



Release Notes - Sonar - Version 2.3

Bug

  • [SONAR-343] - When a rule is removed from the repository, it should be remove from the DB as well
  • [SONAR-440] - Warning when some rules are not imported from a checkstyle and/or PMD configuration file(s)
  • [SONAR-942] - Export rules configuration fails when quality profile name contains the '.' character
  • [SONAR-1073] - Column "RULE_FAILURES"."MESSAGE" is too short (maximum : 500)
  • [SONAR-1137] - When no rule engine exist on a language, all other rules are shown on the screen
  • [SONAR-1315] - Automatically filter Findbugs violations and Code coverage metrics on classes without sources
  • [SONAR-1342] - The pluginKey associated to an active rule can be wrong
  • [SONAR-1480] - No way to export Findbugs rules in a XML file and then to reimport this file to create a new Quality profile
  • [SONAR-1549] - The Sonar profile creation form doesn't allow to import checkstyle,pmd and Findbugs conf files when several langages are defined
  • [SONAR-1637] - Getting "Java inner classes are not supported" Sonar error when analyzing Cobertura report
  • [SONAR-1638] - Warning while parsing enums
  • [SONAR-1644] - A protected method from a class A which is only used by classes extended A are badly considered as dead code.
  • [SONAR-1654] - Export rules in rules engine exports everything (Java, PHP, VB...) when you select any in plugins
  • [SONAR-1666] - Some Findbugs violations are missing in the Sonar web interface
  • [SONAR-1685] - The maven plugin fails if the property sonar.host.url ends with a slash
  • [SONAR-1687] - Filters fail when three criteria are defined
  • [SONAR-1689] - Sorting on alerts does not work anymore
  • [SONAR-1693] - Server-side extensions can not use external dependencies
  • [SONAR-1697] - XML default property values are not correctly displayed in the Settings pages
  • [SONAR-1702] - NoClassDefFoundError when using sonar-ws-client with Commons HttpClient 4.0
  • [SONAR-1712] - Fail to delete a filter if embedded database
  • [SONAR-1715] - Web Services Java Client lib : socket timeout not set
  • [SONAR-1721] - Checkstyle violation is reported for MethodParamPad since Sonar seems to be missing option in rule
  • [SONAR-1727] - Warning when aggregating empty distributions
  • [SONAR-1736] - Description of the Checkstyle "Visibility Modifier" rule is error prone
  • [SONAR-1738] - NPE in EmbeddedDatabaseFactorywhen using JNDI datasource
  • [SONAR-1751] - The method org.sonar.gwt.Utils.getPageWidth() returns 0 in IE6
  • [SONAR-1753] - Time Machine chart is not secured
  • [SONAR-1758] - Unit test EventUnmarshallerTest on ws-client module can fail according to the timezone of the machine
  • [SONAR-1767] - Violations do not show when using id instead of kee in violation drilldown to reference rule
  • [SONAR-1768] - Import of Checkstyle configuration with "message" element fails
  • [SONAR-1774] - AbstractTokenizer does not add token entries
  • [SONAR-1793] - Wrong URL construction in ViolationQuery, when depth parameter used
  • [SONAR-1802] - Can't import FindBugs profile when some rules are duplicated in the findbugs.xml configuration file
  • [SONAR-1805] - The PMD rule CloneMethodMustImplementCloneable is badly configured in the Sonar Way quality profile (and so not activated in this default profile)
  • [SONAR-1812] - The declaration @BelongsTo(classes=GeneratesViolations.class) does not work
  • [SONAR-1813] - If the method DecoratorContext.getViolations() is called by a decorator before the ViolationsDecorator, all violations saved between those two decorators are lost
  • [SONAR-1833] - treemap ignores fractional part of metrics
  • [SONAR-1843] - The webservice /api/properties fails when requested format is XML

Improvement

  • [SONAR-236] - Checkstyle implementation only allows one check per Checkstyle class
  • [SONAR-555] - Permalink on Time Machine charts
  • [SONAR-736] - Reuse findbugs reports
  • [SONAR-964] - Multiple Regexp hard to distinguish
  • [SONAR-990] - Add an option to activate/deactivate all the selected rules of the profile admin console
  • [SONAR-1024] - Improve the rules search engine by displaying the number of results for not selected rule level (Inactive rule)
  • [SONAR-1290] - Improve SQL requests on the Q profiles page
  • [SONAR-1328] - Ability to personalize the CheckStyle SuppressionCommentFilter and SuppressWithNearbyCommentFilter modules
  • [SONAR-1404] - Allow to rename quality profile
  • [SONAR-1534] - Activation of all the default FindBugs rules
  • [SONAR-1557] - Findbugs should not analyzed *.jar files stored in the target/classes directory
  • [SONAR-1607] - Missing FindBugs rules
  • [SONAR-1634] - Defining a new metric with existing key results in confusing message
  • [SONAR-1641] - Exclude certain member variables (esp. logger instances) from the LCOM4 calculation
  • [SONAR-1665] - Upgrade to Commons DBCP 2.3
  • [SONAR-1669] - Add info about JDBC driver in the System Info page
  • [SONAR-1670] - Upgrade the MySql driver from version 5.1.6 to 5.1.13
  • [SONAR-1674] - Log user agent in Jetty logs
  • [SONAR-1698] - Remove the "Translation" Checkstyle rule as it works only on property files
  • [SONAR-1701] - API: search profile rules by config key
  • [SONAR-1706] - Depreciate sonar.reuseExistingRulesConfiguration
  • [SONAR-1745] - Add URL parameters to time machine charts
  • [SONAR-1747] - Add the ability to instantiate a new KeywordColorizer with a regular expression
  • [SONAR-1749] - MavenPlugin api, offer way to build nested xml-elements
  • [SONAR-1757] - Improve the error log message when a "javax.persistence.NonUniqueResultException" is thrown
  • [SONAR-1761] - Missing example in the ConstructorCallsOverridableMethod PMD rule description
  • [SONAR-1763] - Optional generation of the Checkstyle XML report
  • [SONAR-1776] - Add a page "Permalinks" to the profile console
  • [SONAR-1778] - Missing description for some system plugins
  • [SONAR-1780] - An exception should be thrown in case when two Sonar plugins try to use the same key
  • [SONAR-1781] - The use of org.sonar.api.batch.AbstractSourceImporter is error prone when importing Unit Test source code
  • [SONAR-1798] - Ability to register a number of points to a rule violation
  • [SONAR-1814] - New extension point : factory of extensions
  • [SONAR-1822] - Add the property 'sonar.skipTendencies' to skip calculation of measure tendencies

New Feature

  • [SONAR-738] - Honor Checkstyle Suppressions XML Document
  • [SONAR-1229] - Export/Import a given Sonar quality profile
  • [SONAR-1709] - Add static resources to plugins
  • [SONAR-1766] - Create a new PMD XPath rule and let user duplicate this rule as often as necessary

martes, 11 de agosto de 2009

Instalando Sonar usando MySQL en Tomcat 6

Sonar es una herramienta para administrar la calidad del código fuente en Java la cual se basa en otras herramientas de análisis como findbugs, PMD, cobertura, checkstyles, etc. Esta herramienta se encarga de recolectar los resultados de los diferentes análisis y los guarda en un histórico lo cual permite ver la evolución de un proyecto en el tiempo. 

La instalación por defecto de Sonar es muy sencilla, solo se debe descomprimir el instalador en formato zip y ejecutar el script asociado a la plataforma que se encuentra en la carpeta bin. La base de datos usada por la aplicación por defecto es Derby, aunque el equipo técnico de Sonar recomiendan usar otra BD para ambientes que no sean de pruebas. 

En este articulo voy a describir los pasos necesarios para instalarla en Tomcat usando como base de datos MySQL.

A continuación detallo los pasos a realizar:

Lo primero es crear la base de datos en MySQL y asignar los privilegios de acceso al usuario sonar (o cualquiera que se desee usar). Las tablas son creadas cuando se arranca la aplicación por primera vez



mysql -u root -p

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
grant all privileges on sonar.* to 'sonar'@'localhost' identified by 'password';
flush privileges;


El siguiente paso consiste en configurar Sonar. Para eso lo primero que hay que hacer es descomprimir en un directorio temporal el instalador. Luego buscamos el archivo sonar.properties en la carpeta conf y editamos los parámetros de conexión a la bd.



Se comenta la configuración de la bd Derby



#sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.validationQuery: values(1)


Y se des-comenta y se ajustan los parámetros de MySQL



sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
sonar.jdbc.validationQuery: select 1


sonar.jdbc.username: sonar
sonar.jdbc.password: password

El siguiente paso es la creación del war. Para eso debemos cambiarnos al directorio war dentro de la instalación de sonar y ejecutar el script build-war.sh

cd ../war
./build-war.sh

Si se usa tomcat 5 no hay necesidad de ajustar la configuración de tomcat ya que es soportado directamente por sonar. En nuestro caso vamos a usar Tomcat 6 (6.0.18 en mi caso) y para que funcione debemos hacer un pequeño cambio en el script $TOMCAT_HOME/bin/catalina.sh. Debemos editar el script y agregar la siguiente linea al principio

# Soporte Sonar
JAVA_OPTS="-Dfile.encoding=UTF-8 -server -XX:PermSize=256m -Djava.awt.headless=true"

Hay otros sitios donde especifican el uso de otros parámetros pero a mi me funciono bien con la definición de arriba.


Ya lo único que nos queda es hacer deploy del war y configurar maven para que pueda registrar la información en la bd.


Para hacer deploy solo basta copiar el war en la carpeta $TOMCAT_HOME/webapps y reiniciar tomcat

$TOMCAT_HOME/bin/shutdown.sh
cp -p sonar.war $TOMCAT_HOME/webapps
$TOMCAT_HOME/bin/startup.sh

y para configurar maven solo debemos definir el siguiente perfil en el archivo {home}/.m2/settings.xml. La configuracion incluye los parametros de conexion a la bd.

<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- EXAMPLE FOR MYSQL -->
<sonar.jdbc.url>
jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
</sonar.jdbc.url>
<sonar.jdbc.driver>com.mysql.jdbc.Driver</sonar.jdbc.driver>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>mipassword</sonar.jdbc.password>
<!-- SERVER ON A REMOTE HOST -->
<sonar.host.url>https://www.mycompany.com/sonar</sonar.host.url>
</properties>
</profile>
</profiles>

<activeProfiles>
<activeProfile>sonar</activeProfile>
</activeProfiles>



Lo único que nos falta es recopilar la información usando maven, lo cual lo podemos hacer con el siguiente comando

mvn clean package sonar:sonar

Y luego revisar la información desde sonar.