danielstjules / jsinspect

Detect copy-pasted and structurally similar code
MIT License
3.56k stars 128 forks source link

Strip indent #6

Closed alexeyraspopov closed 9 years ago

alexeyraspopov commented 9 years ago

Hi!

At first, I was so exited when I found this tool. Thank you.

I was trying to use it for my project and got interesting behaviour: when I have two blocks of code which are the same but have different indentation level diff shows me incorrect add/remove lines (actually it shows that every string was replaced because of different indentation level).

I used strip-indent for blocks of code which will be matched.

Also, If you will allow it, I've added .editorconfig manifest with line ending setting. I work on Windows laptop and when I first started the tests I've got error because of different line ending in specs and in files (\n and \r\n).

Kind regards, Alexey Raspopov

alexeyraspopov commented 9 years ago

Also, there is an example.

Diff before:

- c:/a.js:653,660
+ c:/a.js:942,949
+              update: function () {
+                  setTimeout(function () {
+                      div.css({
+                          top: 545,
+                          left: 270
+                      });
+                  }, 0);
+              }
-          update: function () {
-              setTimeout(function () {
-                  div.css({
-                      top: 195,
-                      left: 68
-                  });
-              }, 0);
-          }

After:

- c:/a.js:653,660
+ c:/a.js:942,949
   update: function () {
       setTimeout(function () {
           div.css({
+              top: 545,
+              left: 270
-              top: 195,
-              left: 68
           });
       }, 0);
   }
danielstjules commented 9 years ago

Looks good, thanks! :)