danielstjules / jsinspect

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

Ability to skip 'the following section' #27

Open jonbcampos opened 8 years ago

jonbcampos commented 8 years ago

Similar to istanbul it would be nice to skip sections with code inserts. In my angularjs app many of the modules start with a similar 'imports' section and they are all stating they are duplicates. Yes they are, but I accept these sections and would like to focus on the meat and potatoes

danielstjules commented 8 years ago

Can you post a small example reproduce case? Are the imports es6 module syntax?

jonbcampos commented 8 years ago

Not a problem:

 var listtimesheetsModule = angular.module('app.sections.timesheets.list', [
     'ui.router',
     // models
     'models.SessionModel',
     'models.TimesheetsModel',
     'models.EditableWeeksModel',
     'models.WeeksModel',
     // filters
     'common.helpers.createError',
     'app.filters.getTimesheetStatusById',
     'app.filters.getWeekLabelById'
 ]);
danielstjules commented 8 years ago

Thanks! Somewhat related to https://github.com/danielstjules/jsinspect/issues/26 I'll need to setup better detection of this kind of dependency-related code, as I've currently hardcoded checks for AMD/CommonJS/ES6 style modules.

jonbcampos commented 8 years ago

Great to hear. With istanbul I can add the following tag over a function/block-of-code and it will be ignored. I'd love this same ability.

 /* istanbul ignore next */
danielstjules commented 8 years ago

Might be nice to have some config for this as well. Maybe skipping blocks that start with a given line? Since there's a pattern here, I'd like that better than having QA tools pollute lib code

jonbcampos commented 8 years ago

True. While I don't like adding a lot of tags to code, it does provide flexibility. And since it is stripped out during the build process I really don't mind the extra lines added near my jsdoc. But I do like the idea of specifying a specific known repeating block. On Oct 15, 2015 2:23 AM, "Daniel St. Jules" notifications@github.com wrote:

Might be nice to have some config for this as well. Maybe skipping blocks that start with a given line? Since there's a pattern here, I'd like that better than having QA tools pollute lib code

— Reply to this email directly or view it on GitHub https://github.com/danielstjules/jsinspect/issues/27#issuecomment-148303620 .

danielstjules commented 7 years ago

Thinking about this again, would this feature ignore only the next line, or all nodes contained in that line? And thus potentially multiples lines if a node spans that many?