Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-6939

Allow plugins to override the decimal scale of float metrics

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.3
    • Component/s: Database
    • Labels:
      None

      Description

      Scale of decimal measures was restricted to 1 when storing measures into database. As the scale is used by web services/webapp to format measure values, it must be known and defined on decimal metrics:

      public class MyMetric implements Metrics {
      
        public static final String KEY = "my_metric";
      
        private static final Metric<> METRIC = new Metric.Builder(KEY, "My Metric", Metric.ValueType.FLOAT)
          .setDescription("My metric")
      
          // here is the change, available since API 5.3
          .setDecimalScale(4)
          .create();
      
        @Override
        public List getMetrics() {
          return Collections.singletonList(METRIC);
        }
      }
      

      Note that this feature is not available for manual custom metrics. Web services api/metrics/create and api/custom_measures/create do not allow to override the default scale, which is 1.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fabrice.bellingard Fabrice Bellingard
              Reporter:
              julien.lancelot Julien Lancelot
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: