Skip to content

Commit d82df67

Browse files
authored
Merge pull request #2223 from StoDevX/remove-danger-checks
Remove some faulty Danger checks
2 parents dfa5ef3 + 7f61d9e commit d82df67

File tree

3 files changed

+1
-198
lines changed

3 files changed

+1
-198
lines changed

dangerfile.js

Lines changed: 0 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import yarn from 'danger-plugin-yarn'
88

99
// utilities
1010
import uniq from 'lodash/uniq'
11-
import isEqual from 'lodash/isEqual'
1211
import findIndex from 'lodash/findIndex'
13-
import plist from 'simple-plist'
1412

1513
async function main() {
1614
const taskName = String(process.env.task)
@@ -198,8 +196,6 @@ async function runJSのGeneral() {
198196
await bigPr()
199197
await exclusionaryTests()
200198
await xcodeproj()
201-
await gradle()
202-
await infoPlist()
203199
}
204200

205201
// New js files should have `@flow` at the top
@@ -263,7 +259,6 @@ async function xcodeproj() {
263259
await pbxprojBlankLine()
264260
await pbxprojLeadingZeros()
265261
await pbxprojDuplicateLinkingPaths()
266-
await pbxprojSidebarSorting()
267262
}
268263

269264
// Warn about a blank line that Xcode will re-insert if we remove
@@ -347,194 +342,6 @@ async function pbxprojDuplicateLinkingPaths() {
347342
)
348343
}
349344

350-
// Warn about non-sorted frameworks in xcode sidebar
351-
async function pbxprojSidebarSorting() {
352-
const pbxprojPath = danger.git.modified_files.find(filepath =>
353-
filepath.endsWith('project.pbxproj'),
354-
)
355-
const xcodeproj = await parseXcodeProject(pbxprojPath)
356-
357-
const projectsInSidebar = xcodeproj.project.objects.PBXGroup
358-
const sidebarSorting = Object.entries(projectsInSidebar)
359-
.filter(([_, val] /*: [string, any]*/) => typeof val === 'object')
360-
.filter(([_, val] /*: [string, any]*/) => val.name === 'Libraries')
361-
.filter(([_, val] /*: [string, any]*/) => val.files)
362-
.filter(([_, val] /*: [string, any]*/) => {
363-
const projects = val.files.map(file => file.comment)
364-
const sorted = [...projects].sort((a, b) => a.localeSort(b))
365-
return !isEqual(projects, sorted)
366-
})
367-
368-
if (sidebarSorting.length) {
369-
return
370-
}
371-
372-
warn(
373-
h.details(
374-
h.summary(
375-
"Some of the iOS frameworks aren't sorted alphabetically in the Xcode sidebar (under Libraries). Please sort them alphabetically. Thanks!",
376-
),
377-
"If you right-click on the Libraries group in the sidebar, you can just pick 'Sort by Name' and Xcode will do it for you.",
378-
),
379-
)
380-
}
381-
382-
// Make sure the Info.plist `NSLocationWhenInUseUsageDescription` didn't switch to entities
383-
function infoPlist() {
384-
const infoPlistChanged = danger.git.modified_files.find(filepath =>
385-
filepath.endsWith('Info.plist'),
386-
)
387-
if (!infoPlistChanged) {
388-
return
389-
}
390-
391-
const parsed = plist.parse(readFile(infoPlistChanged))
392-
const descKeysWithEntities = Object.keys(parsed)
393-
.filter(key => key.endsWith('Description'))
394-
.filter(key => parsed[key].includes("'")) // look for single quotes
395-
396-
if (!descKeysWithEntities.length) {
397-
return
398-
}
399-
400-
warn(
401-
h.details(
402-
h.summary(
403-
'Some Info.plist descriptions were rewritten by something to include single quotes.',
404-
),
405-
h.p(
406-
"Xcode will rewrite them to use the <code>&amp;apos;</code> XML entity; would you please change them for us, so that Xcode doesn't have to?",
407-
),
408-
h.ul(
409-
...descKeysWithEntities.map(key => {
410-
const val = entities.encode(parsed[key])
411-
const escaped = entities.encode(val.replace(/'/g, '&apos;'))
412-
return h.li(
413-
h.p(h.code(key) + ':'),
414-
h.blockquote(val),
415-
h.p('should become'),
416-
h.blockquote(escaped),
417-
)
418-
}),
419-
),
420-
),
421-
)
422-
}
423-
424-
async function gradle() {
425-
await buildDotGradle()
426-
await mainDotJava()
427-
await settingsDotGradleSpacing()
428-
}
429-
430-
// Ensure that the build.gradle dependencies list is sorted
431-
function buildDotGradle() {
432-
const buildDotGradle = danger.git.modified_files.find(
433-
filepath => filepath === 'android/app/build.gradle',
434-
)
435-
if (!buildDotGradle) {
436-
return
437-
}
438-
439-
const file = readFile(buildDotGradle).split('\n')
440-
const startLine = findIndex(file, line => line === 'dependencies {')
441-
const endLine = findIndex(file, line => line === '}', startLine)
442-
443-
const linesToSort = file
444-
.slice(startLine + 1, endLine - 1)
445-
.map(line => line.trim())
446-
.filter(line => !line.startsWith('//'))
447-
448-
const sorted = [...linesToSort].sort()
449-
450-
if (isEqual(linesToSort, sorted)) {
451-
return
452-
}
453-
454-
const firstEntry = linesToSort[0]
455-
warn(
456-
h.details(
457-
h.summary(
458-
"We like to keep the <code>build.gradle</code>'s list of dependencies sorted alphabetically.",
459-
),
460-
h.p(`Was the first entry, <code>${firstEntry}</code>, out of place?`),
461-
),
462-
)
463-
}
464-
465-
// Ensure that the MainApplication.java imports list is sorted
466-
function mainDotJava() {
467-
const mainDotJava = danger.git.modified_files.find(filepath =>
468-
filepath.endsWith('MainApplication.java'),
469-
)
470-
if (!mainDotJava) {
471-
return
472-
}
473-
474-
const file = readFile(mainDotJava).split('\n')
475-
const startNeedle = '// keep these sorted alphabetically'
476-
const startLine = findIndex(file, line => line === startNeedle)
477-
const endLine = findIndex(file, line => line === '', startLine)
478-
479-
const linesToSort = file
480-
.slice(startLine + 1, endLine - 1)
481-
.map(line => line.trim())
482-
483-
const sorted = [...linesToSort].sort()
484-
485-
if (isEqual(linesToSort, sorted)) {
486-
return
487-
}
488-
489-
// react-native link inserts the new import right after the RN import
490-
const rnImportLine = findIndex(
491-
file,
492-
line => line === 'import com.facebook.react.ReactApplication;',
493-
)
494-
const problemEntry = file[rnImportLine + 1]
495-
const problemLine = rnImportLine - startLine + 1
496-
warn(
497-
h.details(
498-
h.summary(
499-
"We like to keep the <code>MainApplication.java</code>'s list of imports sorted alphabetically.",
500-
),
501-
h.p(
502-
`Was the number ${problemLine} entry, <code>${problemEntry}</code>, out of place?`,
503-
),
504-
),
505-
)
506-
}
507-
508-
// Enforce spacing in the settings.gradle file
509-
function settingsDotGradleSpacing() {
510-
const settingsDotGradle = danger.git.modified_files.find(
511-
filepath => filepath === 'android/settings.gradle',
512-
)
513-
if (!settingsDotGradle) {
514-
return
515-
}
516-
517-
const file = readFile(settingsDotGradle).split('\n')
518-
const startLine = findIndex(file, line => line.startsWith('//'))
519-
const firstInclusionLine = findIndex(file, line => line.startsWith('include'))
520-
521-
if (firstInclusionLine >= startLine) {
522-
return
523-
}
524-
525-
const firstEntry = file[firstInclusionLine]
526-
warn(
527-
h.details(
528-
h.summary(
529-
"We like to keep the <code>settings.gradle</code>'s list of imports sorted alphabetically.",
530-
),
531-
h.p(
532-
`It looks like the first entry, <code>${firstEntry}</code>, is out of place.`,
533-
),
534-
),
535-
)
536-
}
537-
538345
//
539346
// task=JS-flow
540347
//
@@ -630,9 +437,6 @@ import util from 'util'
630437

631438
const execFile = util.promisify(childProcess.execFile)
632439

633-
const {XmlEntities} = require('html-entities')
634-
const entities = new XmlEntities()
635-
636440
function fastlaneBuildLogTail(log /*: Array<string>*/, message /*: string*/) {
637441
const n = 150
638442
const logToPost = log

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
"pretty-quick": "1.2.2",
142142
"prop-types": "15.6.0",
143143
"react-test-renderer": "16.2.0",
144-
"simple-plist": "0.2.1",
145144
"string-natural-compare": "2.0.2",
146145
"strip-ansi": "4.0.0",
147146
"xcode": "1.0.0"

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5396,7 +5396,7 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
53965396
version "3.0.2"
53975397
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
53985398

5399-
simple-plist@0.2.1, simple-plist@^0.2.1:
5399+
simple-plist@^0.2.1:
54005400
version "0.2.1"
54015401
resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-0.2.1.tgz#71766db352326928cf3a807242ba762322636723"
54025402
dependencies:

0 commit comments

Comments
 (0)