brodycj / create-react-native-module

MIT License
664 stars 52 forks source link

useless `namespace` parameter - followup items #274

Open brodycj opened 4 years ago

brodycj commented 4 years ago

Followup to PR #264 (remove Windows (C#) support): I discovered while using Stryker for mutation testing on some other work that the namespace is no longer needed and should be removed. Here are the surviving namespace mutants that I discovered (shown with diff highlighting):

267. [Survived] ObjectLiteral
/home/brodybits/create-react-native-module/lib/normalized-options.js:35:8
-         : { namespace: pascalCase(name).split(/(?=[A-Z])/).join('.') },
+         : {},

Ran all tests for this mutant.
270. [Survived] StringLiteral
/home/brodybits/create-react-native-module/lib/normalized-options.js:35:62
-         : { namespace: pascalCase(name).split(/(?=[A-Z])/).join('.') },
+         : { namespace: pascalCase(name).split(/(?=[A-Z])/).join("") },

Ran all tests for this mutant.

I can think of a couple more several important items to be addressed at some point - updated:

brodycj commented 4 years ago

When looking at the logging in lib/lib.js I discovered a couple of places in that source file where namespace can now be removed like this:

$ git diff -U7 lib/lib.js
diff --git a/lib/lib.js b/lib/lib.js
index e871115..bac574e 100644
--- a/lib/lib.js
+++ b/lib/lib.js
@@ -63,15 +63,14 @@ const npmAddScriptSync = (packageJsonPath, script, fs) => {
 const generateWithNormalizedOptions = ({
   name,
   prefix,
   moduleName,
   className,
   modulePrefix,
   packageIdentifier = DEFAULT_PACKAGE_IDENTIFIER,
-  namespace,
   platforms = DEFAULT_PLATFORMS,
   tvosEnabled = false,
   githubAccount = DEFAULT_GITHUB_ACCOUNT,
   authorName = DEFAULT_AUTHOR_NAME,
   authorEmail = DEFAULT_AUTHOR_EMAIL,
   license = DEFAULT_LICENSE,
   view = false,
@@ -160,15 +159,14 @@ const generateWithNormalizedOptions = ({

         return true;
       }).map((template) => {
         const templateArgs = {
           name: className,
           moduleName,
           packageIdentifier,
-          namespace,
           platforms,
           tvosEnabled,
           githubAccount,
           authorName,
           authorEmail,
           license,
           view,

I wonder if it should be possible for Stryker to help find this kind of mutation due to members not needed or members not properly tested, as I had discovered in extra breaking mutations that I reported in #89.