From 90af9fc3abc06a6c4784d50924df1fca8fbf661b Mon Sep 17 00:00:00 2001
From: rtaum <rtaum@users.noreply.github.com>
Date: Sun, 9 Dec 2018 11:39:35 +0100
Subject: [PATCH] feat: refactor raiseDeprecationWarnings into
 suppressNotifications (#2921)

---
 lib/config/definitions.js                                 | 7 +------
 lib/config/migration.js                                   | 7 +++++++
 lib/workers/repository/process/deprecated.js              | 2 +-
 test/config/__snapshots__/migration.spec.js.snap          | 3 +++
 test/config/migration.spec.js                             | 1 +
 test/workers/repository/process/deprecated.spec.js        | 4 ++--
 test/workers/repository/process/extract-update.spec.js    | 1 +
 .../repository/updates/__snapshots__/flatten.spec.js.snap | 8 --------
 website/docs/configuration-options.md                     | 2 --
 9 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/lib/config/definitions.js b/lib/config/definitions.js
index 81a5dbff05..964709adc1 100644
--- a/lib/config/definitions.js
+++ b/lib/config/definitions.js
@@ -1302,12 +1302,6 @@ const options = [
     mergeable: true,
     cli: false,
   },
-  {
-    name: 'raiseDeprecationWarnings',
-    description: 'Raise deprecation warnings in issues whenever found',
-    type: 'boolean',
-    default: true,
-  },
   {
     name: 'hostRules',
     description: 'Host rules/configuration including credentials',
@@ -1359,6 +1353,7 @@ const options = [
       'prEditNotification',
       'branchAutomergeFailure',
       'lockFileErrors',
+      'deprecationWarningIssues',
     ],
     cli: false,
     env: false,
diff --git a/lib/config/migration.js b/lib/config/migration.js
index e152def7f9..1854374a27 100644
--- a/lib/config/migration.js
+++ b/lib/config/migration.js
@@ -389,6 +389,13 @@ function migrateConfig(config) {
           .replace(/newVersion/g, 'newValue')
           .replace(/newValueMajor/g, 'newMajor')
           .replace(/newValueMinor/g, 'newMinor');
+      } else if (key === 'raiseDeprecationWarnings') {
+        isMigrated = true;
+        delete migratedConfig.raiseDeprecationWarnings;
+        if (val === false) {
+          migratedConfig.suppressNotifications = migratedConfig.suppressNotifications || [];
+          migratedConfig.suppressNotifications.push('deprecationWarningIssues');
+        }
       }
     }
     if (migratedConfig.endpoints) {
diff --git a/lib/workers/repository/process/deprecated.js b/lib/workers/repository/process/deprecated.js
index ba884ad619..fc43da6d9c 100644
--- a/lib/workers/repository/process/deprecated.js
+++ b/lib/workers/repository/process/deprecated.js
@@ -3,7 +3,7 @@ module.exports = {
 };
 
 async function raiseDeprecationWarnings(config, packageFiles) {
-  if (!config.raiseDeprecationWarnings) {
+  if (config.suppressNotifications && config.suppressNotifications.includes('deprecationWarningIssues')) {
     return;
   }
   const deprecatedPackages = {};
diff --git a/test/config/__snapshots__/migration.spec.js.snap b/test/config/__snapshots__/migration.spec.js.snap
index 85445846bb..3bbeb5c14b 100644
--- a/test/config/__snapshots__/migration.spec.js.snap
+++ b/test/config/__snapshots__/migration.spec.js.snap
@@ -128,6 +128,9 @@ Object {
   "separateMajorMinor": true,
   "separateMajorReleases": true,
   "separateMinorPatch": true,
+  "suppressNotifications": Array [
+    "deprecationWarningIssues",
+  ],
   "travis": Object {
     "enabled": true,
   },
diff --git a/test/config/migration.spec.js b/test/config/migration.spec.js
index 0f9b16cb84..5078069a91 100644
--- a/test/config/migration.spec.js
+++ b/test/config/migration.spec.js
@@ -85,6 +85,7 @@ describe('config/migration', () => {
             schedule: 'before 5am on Mondays',
           },
         ],
+        raiseDeprecationWarnings: false,
       };
       const parentConfig = { ...defaultConfig, semanticCommits: false };
       const { isMigrated, migratedConfig } = configMigration.migrateConfig(
diff --git a/test/workers/repository/process/deprecated.spec.js b/test/workers/repository/process/deprecated.spec.js
index 64696a1492..efb416f4e2 100644
--- a/test/workers/repository/process/deprecated.spec.js
+++ b/test/workers/repository/process/deprecated.spec.js
@@ -6,13 +6,13 @@ describe('workers/repository/process/deprecated', () => {
   describe('raiseDeprecationWarnings()', () => {
     it('returns if disabled', async () => {
       const config = {
-        raiseDeprecationWarnings: false,
+        suppressNotifications: ['deprecationWarningIssues'],
       };
       await raiseDeprecationWarnings(config, {});
     });
     it('raises deprecation warnings', async () => {
       const config = {
-        raiseDeprecationWarnings: true,
+        suppressNotifications: [],
       };
       const packageFiles = {
         npm: [
diff --git a/test/workers/repository/process/extract-update.spec.js b/test/workers/repository/process/extract-update.spec.js
index 9747ee324f..15c30e79e7 100644
--- a/test/workers/repository/process/extract-update.spec.js
+++ b/test/workers/repository/process/extract-update.spec.js
@@ -16,6 +16,7 @@ describe('workers/repository/process/extract-update', () => {
     it('runs', async () => {
       const config = {
         repoIsOnboarded: true,
+        suppressNotifications: ['deprecationWarningIssues']
       };
       await extractAndUpdate(config);
     });
diff --git a/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap b/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap
index e7a6f598f1..d6ac38b779 100644
--- a/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap
+++ b/test/workers/repository/updates/__snapshots__/flatten.spec.js.snap
@@ -64,7 +64,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": null,
@@ -158,7 +157,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": null,
@@ -249,7 +247,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": true,
@@ -346,7 +343,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": null,
@@ -437,7 +433,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": true,
@@ -534,7 +529,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": null,
@@ -628,7 +622,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": null,
@@ -722,7 +715,6 @@ Array [
     "prHourlyLimit": 0,
     "prNotPendingHours": 25,
     "prTitle": null,
-    "raiseDeprecationWarnings": true,
     "rangeStrategy": "replace",
     "rebaseLabel": "rebase",
     "rebaseStalePrs": null,
diff --git a/website/docs/configuration-options.md b/website/docs/configuration-options.md
index 7ce1a7a39c..1636d60b0d 100644
--- a/website/docs/configuration-options.md
+++ b/website/docs/configuration-options.md
@@ -686,8 +686,6 @@ The PR title is important for some of Renovate's matching algorithms (e.g. deter
 
 Currently the only Python package manager is `pip` - specifically for `requirements.txt` and `requirequirements.pip` files - so adding any config to this `python` object is essentially the same as adding it to the `pip_requirements` object instead.
 
-## raiseDeprecationWarnings
-
 ## rangeStrategy
 
 Behaviour:
-- 
GitLab