c ++社区管理器声纳插件未能解析cppcheck报告

时间:2016-05-25 14:48:10

标签: sonarqube sonar-runner cppcheck

我正在尝试使用c ++社区插件解析声纳中的cppcheck报告。我收到以下错误

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Imaging;

namespace WpfApplication56
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }

    public class VM // I didn't implement INotifyPropertyChanged because it doesn't matter for this question
    {
        public Uri InitialImage { get; set; }
        public Uri MouseLeftButtonDownImage { get; set; }
        public Uri MouseLeftButtonUpImage { get; set; }
    }

    public class MyButton
    {
        // Attached Properties
        #region MouseEnterCursorProperty
        public static Cursor GetMouseEnterCursor(DependencyObject obj)
        {
            return (Cursor)obj.GetValue(MouseEnterCursorProperty);
        }
        public static void SetMouseEnterCursor(DependencyObject obj, Cursor value)
        {
            obj.SetValue(MouseEnterCursorProperty, value);
        }
        public static readonly DependencyProperty MouseEnterCursorProperty = DependencyProperty.RegisterAttached("MouseEnterCursor", typeof(Cursor), typeof(MyButton), new PropertyMetadata(null, OnPropertyChanged));
        #endregion
        #region InitialImageProperty
        public static Uri GetInitialImage(DependencyObject obj)
        {
            return (Uri)obj.GetValue(InitialImageProperty);
        }
        public static void SetInitialImage(DependencyObject obj, Uri value)
        {
            obj.SetValue(InitialImageProperty, value);
        }
        public static readonly DependencyProperty InitialImageProperty = DependencyProperty.RegisterAttached("InitialImage", typeof(Uri), typeof(MyButton), new PropertyMetadata(null, OnPropertyChanged));
        #endregion
        #region MouseLeftButtonDownProperty
        public static Uri GetMouseLeftButtonDown(DependencyObject obj)
        {
            return (Uri)obj.GetValue(MouseLeftButtonDownProperty);
        }
        public static void SetMouseLeftButtonDown(DependencyObject obj, Uri value)
        {
            obj.SetValue(MouseLeftButtonDownProperty, value);
        }
        public static readonly DependencyProperty MouseLeftButtonDownProperty = DependencyProperty.RegisterAttached("MouseLeftButtonDown", typeof(Uri), typeof(MyButton), new PropertyMetadata(null, OnPropertyChanged));
        #endregion
        #region MouseLeftButtonUpProperty
        public static Uri GetMouseLeftButtonUp(DependencyObject obj)
        {
            return (Uri)obj.GetValue(MouseLeftButtonUpProperty);
        }
        public static void SetMouseLeftButtonUp(DependencyObject obj, Uri value)
        {
            obj.SetValue(MouseLeftButtonUpProperty, value);
        }
        public static readonly DependencyProperty MouseLeftButtonUpProperty = DependencyProperty.RegisterAttached("MouseLeftButtonUp", typeof(Uri), typeof(MyButton), new PropertyMetadata(null, OnPropertyChanged));
        #endregion

        // Called when the value for an attached property has changed
        private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Button b = d as Button;
            if (b == null)
                return;

            if (e.Property.Equals(MouseEnterCursorProperty))
            {
                b.MouseEnter -= MouseEnter; // In case the property changes more than once we don't want to hook it more than once
                b.MouseEnter += MouseEnter;
            }
            else if (e.Property.Equals(InitialImageProperty))
            {
                SetButtonImage(b, GetInitialImage(b));
            }
            else if (e.Property.Equals(MouseLeftButtonDownProperty))
            {
                // Had to use Preview because non-Preview never fired
                b.PreviewMouseLeftButtonDown -= MouseLeftButtonDown;
                b.PreviewMouseLeftButtonDown += MouseLeftButtonDown;
            }
            else if (e.Property.Equals(MouseLeftButtonUpProperty))
            {
                // Had to use Preview because non-Preview never fired
                b.PreviewMouseLeftButtonUp -= MouseLeftButtonUp;
                b.PreviewMouseLeftButtonUp += MouseLeftButtonUp;
            }
        }

        private static void MouseEnter(object sender, MouseEventArgs e)
        {
            Button b = sender as Button;
            if (b == null)
                return;
            b.Cursor = GetMouseEnterCursor(b);
            e.Handled = false;
        }

        private static void MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Button b = sender as Button;
            if (b == null)
                return;
            SetButtonImage(b, GetMouseLeftButtonDown(b));
            e.Handled = false;
        }
        private static void MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Button b = sender as Button;
            if (b == null)
                return;
            SetButtonImage(b, GetMouseLeftButtonUp(b));
            e.Handled = false;
        }

        private static void SetButtonImage(Button b, Uri uri)
        {
            if (b == null || uri == null)
                return;

            var img = b.Content as Image;
            if (img == null)
                img = new Image();
            BitmapImage bm = new BitmapImage();
            bm.BeginInit();
            bm.UriSource = uri;
            bm.EndInit();
            img.Source = bm;

            b.Content = img;
        }
    }
}

我猜2403错误来自之前的有效解析。

我使用此命令在Windows命令行上运行cppcheck

INFO  - Sensor CxxCppCheckSensor
DEBUG - Normalized report includes to '[C:\Program Files (x86)\Jenkins\workspace\IHM TR\cppCheckTmp.xml]'
DEBUG - Adding report 'C:\Program Files (x86)\Jenkins\workspace\IHM TR\cppCheckTmp.xml'
INFO  - Processing report 'C:\Program Files (x86)\Jenkins\workspace\IHM TR\cppCheckTmp.xml'
INFO  - Parsing 'Cppcheck V2' format
INFO  - Parsing 'Cppckeck V1' format
ERROR - Report C:\Program Files (x86)\Jenkins\workspace\IHM TR\cppCheckTmp.xml cannot be parsed
INFO  - CppCheck Errors processed = 2403
INFO  - Sensor CxxCppCheckSensor (done) | time=1512ms

然后用这个声纳

"C:\Program Files\Cppcheck\cppcheck.exe" --xml-version=2 --platform=win64 --force --enable=all --suppress=variableScope .  2> cppCheckTmp.xml

您是否有任何线索来调查解析失败的原因?

配置

C ++社区插件版本:v0.9.5

Jenkins,声纳和cppcheck运行并安装在Windows服务器2008 R2上

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。以前,我无法在10.000行cppCheck xml报告中检测到错误的来源。

我用Google Chrome打开了xml报告,很好地给了我错误的列和行。这是带有重音的未使用文件的编码问题。这是错误xml报告行。我终于删除了该文件。