]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10439 Use ranges in facets instead of cumulative numbers (#3141)
authorPascal Mugnier <pascal.mugnier@sonarsource.com>
Fri, 16 Mar 2018 08:46:59 +0000 (09:46 +0100)
committerGitHub <noreply@github.com>
Fri, 16 Mar 2018 08:46:59 +0000 (09:46 +0100)
server/sonar-web/src/main/js/apps/projects/__tests__/utils-test.ts
server/sonar-web/src/main/js/apps/projects/filters/IssuesFilter.tsx
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/CoverageFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/DuplicationsFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/IssuesFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/NewLinesFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/filters/__tests__/__snapshots__/SizeFilter-test.tsx.snap
server/sonar-web/src/main/js/apps/projects/utils.ts
server/sonar-web/src/main/js/helpers/ratings.ts
tests/src/test/java/org/sonarqube/tests/project/ProjectsPageTest.java

index 7fadde28510da206b53fd4469774fbcc1d3bbc62..7f2a5acc5e8c35d27383104e223c9fe3d4588472 100644 (file)
@@ -38,58 +38,3 @@ describe('parseSorting', () => {
     expect(utils.parseSorting('-size')).toEqual({ sortDesc: true, sortValue: 'size' });
   });
 });
-
-describe('cumulativeMapFacetValues', () => {
-  it('should correctly cumulate facets', () => {
-    expect(
-      utils.cumulativeMapFacetValues([
-        { val: '1', count: 50 },
-        { val: '2', count: 1 },
-        { val: '3', count: 6 },
-        { val: '4', count: 2 },
-        { val: '5', count: 0 }
-      ])
-      // eslint-disable-next-line
-    ).toEqual({ '1': 50, '2': 9, '3': 8, '4': 2, '5': 0 });
-  });
-  it('should correctly cumulate facets with NO_DATA items', () => {
-    const expectedResult = {
-      '80.0-*': 59,
-      '70.0-80.0': 26,
-      '50.0-70.0': 15,
-      '30.0-50.0': 11,
-      '*-30.0': 7,
-      NO_DATA: 5
-    };
-    expect(
-      utils.cumulativeMapFacetValues([
-        { val: '80.0-*', count: 59 },
-        { val: '70.0-80.0', count: 11 },
-        { val: '50.0-70.0', count: 4 },
-        { val: '30.0-50.0', count: 4 },
-        { val: '*-30.0', count: 7 },
-        { val: 'NO_DATA', count: 5 }
-      ])
-    ).toEqual(expectedResult);
-    expect(
-      utils.cumulativeMapFacetValues([
-        { val: 'NO_DATA', count: 5 },
-        { val: '80.0-*', count: 59 },
-        { val: '70.0-80.0', count: 11 },
-        { val: '50.0-70.0', count: 4 },
-        { val: '30.0-50.0', count: 4 },
-        { val: '*-30.0', count: 7 }
-      ])
-    ).toEqual(expectedResult);
-    expect(
-      utils.cumulativeMapFacetValues([
-        { val: '80.0-*', count: 59 },
-        { val: '70.0-80.0', count: 11 },
-        { val: '50.0-70.0', count: 4 },
-        { val: 'NO_DATA', count: 5 },
-        { val: '30.0-50.0', count: 4 },
-        { val: '*-30.0', count: 7 }
-      ])
-    ).toEqual(expectedResult);
-  });
-});
index 3eb8afb926cc1eefae8e9111f517cbb760e49ba5..06be03f8cc6249622d28817e948cf30ff39284a1 100644 (file)
@@ -70,8 +70,6 @@ function renderOption(option: number, selected: boolean) {
   return (
     <span>
       <Rating value={option} small={true} muted={!selected} />
-      {option > 1 &&
-        option < 5 && <span className="note spacer-left">{translate('and_worse')}</span>}
     </span>
   );
 }
index 1c61cac529c30989715c908653a738e2f50f9b17..9ce9bc4f61498cc3e02c228cf52bcf53a8e34787 100644 (file)
@@ -37,7 +37,7 @@ exports[`renders 2`] = `
   <span
     className="spacer-left"
   >
-    &lt; 80%
+    70% - 80%
   </span>
 </span>
 `;
index f9794832bdd6c905e20bdc0765c053d115caae94..515a3abecfb2dc07029af11964f4f37861bb569b 100644 (file)
@@ -32,10 +32,5 @@ exports[`renders 2`] = `
     small={true}
     value={2}
   />
-  <span
-    className="note spacer-left"
-  >
-    and_worse
-  </span>
 </span>
 `;
index 135024ac542c841b65469abc40754fae6bd013d4..f956104ccb9f934ad8f7c2ece834521e9db72c68 100644 (file)
@@ -35,7 +35,7 @@ exports[`renders 2`] = `
   <span
     className="spacer-left"
   >
-    ≥ 1k
+    1k - 10k
   </span>
 </span>
 `;
index 5aa2bd869095b2bcb65f5c498a8c1a5909f57a68..b59516613d6c4ad892a804236aa282090ba621a6 100644 (file)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { sumBy, uniq } from 'lodash';
+import { uniq } from 'lodash';
 import { Query, convertToFilter } from './query';
 import { translate } from '../../helpers/l10n';
 import { RequestData } from '../../helpers/request';
@@ -145,21 +145,6 @@ const LEAK_FACETS = [
   'tags'
 ];
 
-const CUMULATIVE_FACETS = [
-  'reliability',
-  'new_reliability',
-  'security',
-  'new_security',
-  'maintainability',
-  'new_maintainability',
-  'coverage',
-  'new_coverage',
-  'duplications',
-  'new_duplications',
-  'size',
-  'new_lines'
-];
-
 const REVERSED_FACETS = ['coverage', 'new_coverage'];
 
 export function localizeSorting(sort?: string): string {
@@ -281,23 +266,6 @@ function mapFacetValues(values: Array<{ val: string; count: number }>) {
   return map;
 }
 
-export function cumulativeMapFacetValues(values: Array<{ val: string; count: number }>) {
-  const noDataVal = values.find(value => value.val === 'NO_DATA');
-  const filteredValues = noDataVal ? values.filter(value => value.val !== 'NO_DATA') : values;
-
-  let sum = sumBy(filteredValues, value => value.count);
-  const map: { [value: string]: number } = {};
-  filteredValues.forEach((value, index) => {
-    map[value.val] = index > 0 && index < values.length - 1 ? sum : value.count;
-    sum -= value.count;
-  });
-
-  if (noDataVal) {
-    map[noDataVal.val] = noDataVal.count;
-  }
-  return map;
-}
-
 function getFacetsMap(facets: Facet[]) {
   const map: { [property: string]: { [value: string]: number } } = {};
   facets.forEach(facet => {
@@ -306,9 +274,7 @@ function getFacetsMap(facets: Facet[]) {
     if (REVERSED_FACETS.includes(property)) {
       values.reverse();
     }
-    map[property] = CUMULATIVE_FACETS.includes(property)
-      ? cumulativeMapFacetValues(values)
-      : mapFacetValues(values);
+    map[property] = mapFacetValues(values);
   });
   return map;
 }
index 3fa98ebd4328de3b6631b6c18fb9478d1f18d6fe..3c60bc5b3581d8b41b155b8d323d1f7b66e9cad2 100644 (file)
@@ -25,7 +25,7 @@ function checkNumberRating(coverageRating: number): void {
 
 export function getCoverageRatingLabel(rating: number): string {
   checkNumberRating(rating);
-  const mapping = ['≥ 80%', '< 80%', '< 70%', '< 50%', '< 30%'];
+  const mapping = ['≥ 80%', '70% - 80%', '50% - 70%', '30% - 50%', '< 30%'];
   return mapping[rating - 1];
 }
 
@@ -37,7 +37,7 @@ export function getCoverageRatingAverageValue(rating: number): number {
 
 export function getDuplicationsRatingLabel(rating: number): string {
   checkNumberRating(rating);
-  const mapping = ['< 3%', '≥ 3%', '> 5%', '> 10%', '> 20%'];
+  const mapping = ['< 3%', '3% - 5%', '5% - 10%', '10% - 20%', '> 20%'];
   return mapping[rating - 1];
 }
 
@@ -49,7 +49,7 @@ export function getDuplicationsRatingAverageValue(rating: number): number {
 
 export function getSizeRatingLabel(rating: number): string {
   checkNumberRating(rating);
-  const mapping = ['< 1k', '≥ 1k', '> 10k', '> 100k', '> 500k'];
+  const mapping = ['< 1k', '1k - 10k', '10k - 100k', '100k - 500k', '> 500k'];
   return mapping[rating - 1];
 }
 
index 3e37f31266152f76704b2eba9967a860dd4da7b8..d0a97b761a5da108576841bd9d7b04e3b60c16fc 100644 (file)
@@ -81,9 +81,9 @@ public class ProjectsPageTest {
     ProjectsPage page = tester.openBrowser().openProjects();
     page.getFacetByProperty("duplications")
       .shouldHaveValue("1", "1")
-      .shouldHaveValue("2", "1")
-      .shouldHaveValue("3", "1")
-      .shouldHaveValue("4", "1")
+      .shouldHaveValue("2", "0")
+      .shouldHaveValue("3", "0")
+      .shouldHaveValue("4", "0")
       .shouldHaveValue("5", "1")
       .shouldHaveValue("6", "0");
   }