Script to lint for copypasta'd file paths that should be generic #123

Closed
steveklabnik opened this Issue Jul 5, 2016 · 17 comments

Comments

Projects
None yet
6 participants
@steveklabnik
Member

steveklabnik commented Jul 5, 2016

One thing we do when showing errors is show file:///projects/bindings in Cargo's output. It'd be nice to somehow catch that this is always the text we use, as it's really easy to copy/paste something and forget to change it.

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Aug 6, 2016

Member

I think the requirements for this are:

  • This should be a script that can be run on a directory of .md files
  • If the script sees a line containing file://, it should check for the text following that to be /projects/
  • If the text following file:// is anything BUT /projects/, print to stderr the filename, line number, and line content (but continue processing the rest of that file and other following files)
  • If any lines containing file:// not followed by /projects/ have been found, the whole script should exit with a nonzero exit status so that we can hook this into travis and have travis fail if we forget this

Is that what you had in mind, @steveklabnik? I'm thinking about tweeting/getting this in TWiR for some help :)

Member

carols10cents commented Aug 6, 2016

I think the requirements for this are:

  • This should be a script that can be run on a directory of .md files
  • If the script sees a line containing file://, it should check for the text following that to be /projects/
  • If the text following file:// is anything BUT /projects/, print to stderr the filename, line number, and line content (but continue processing the rest of that file and other following files)
  • If any lines containing file:// not followed by /projects/ have been found, the whole script should exit with a nonzero exit status so that we can hook this into travis and have travis fail if we forget this

Is that what you had in mind, @steveklabnik? I'm thinking about tweeting/getting this in TWiR for some help :)

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Aug 6, 2016

Member

Here's an example (source):

If there's a directory src that contains a file modules.md that contains this text:

$ cargo build
   Compiling modules v0.1.0 (file:///home/steve/tmp/modules)
src/foo.rs:1:1: 2:2 warning: function is never used: `it_works`,
#[warn(dead_code)] on by default
src/foo.rs:1 fn it_works() {

And I ran whatever-this-script-is src, I would expect to see:

Found lines that need fixed:

modules.md:2    Compiling modules v0.1.0 (file:///home/steve/tmp/modules)

and have the command exit with a nonzero status.

Member

carols10cents commented Aug 6, 2016

Here's an example (source):

If there's a directory src that contains a file modules.md that contains this text:

$ cargo build
   Compiling modules v0.1.0 (file:///home/steve/tmp/modules)
src/foo.rs:1:1: 2:2 warning: function is never used: `it_works`,
#[warn(dead_code)] on by default
src/foo.rs:1 fn it_works() {

And I ran whatever-this-script-is src, I would expect to see:

Found lines that need fixed:

modules.md:2    Compiling modules v0.1.0 (file:///home/steve/tmp/modules)

and have the command exit with a nonzero status.

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Aug 6, 2016

Member

@carols10cents yup, exactly!

Member

steveklabnik commented Aug 6, 2016

@carols10cents yup, exactly!

@carols10cents carols10cents changed the title from lint for file paths to Script to lint for copypasta'd file paths that should be generic Aug 6, 2016

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Aug 6, 2016

Member

Also, do we care if this is implemented in bash, rust, ruby, perl, etc etc? I don't really, it should be easy enough to read/modify in whatever.

Member

carols10cents commented Aug 6, 2016

Also, do we care if this is implemented in bash, rust, ruby, perl, etc etc? I don't really, it should be easy enough to read/modify in whatever.

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Aug 6, 2016

Member

It would be nice if it was in Rust so that we don't introduce Yet Another Dependency.

Member

steveklabnik commented Aug 6, 2016

It would be nice if it was in Rust so that we don't introduce Yet Another Dependency.

@ereichert

This comment has been minimized.

Show comment
Hide comment
@ereichert

ereichert Aug 6, 2016

Contributor

Should it only scan .md files regardless if other files are present?

Do you want the program in a new repo or part of this repo?

Contributor

ereichert commented Aug 6, 2016

Should it only scan .md files regardless if other files are present?

Do you want the program in a new repo or part of this repo?

@bronzdoc

This comment has been minimized.

Show comment
Hide comment
@bronzdoc

bronzdoc Aug 6, 2016

I would like to help with this as a way to start learning rust :)

bronzdoc commented Aug 6, 2016

I would like to help with this as a way to start learning rust :)

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Aug 6, 2016

Member

Should it only scan .md files regardless if other files are present?

Yep!

Do you want the program in a new repo or part of this repo?

In this repo please :)

Yinz are watching the TWiR repo like hawks! :)

Member

carols10cents commented Aug 6, 2016

Should it only scan .md files regardless if other files are present?

Yep!

Do you want the program in a new repo or part of this repo?

In this repo please :)

Yinz are watching the TWiR repo like hawks! :)

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Aug 6, 2016

Member

Hey @ereichert @bronzdoc !

Should it only scan .md files regardless if other files are present?

Yes, because they're the source text, other things are generated from them.

Do you want the program in a new repo or part of this repo?

In this one would be cool!

Member

steveklabnik commented Aug 6, 2016

Hey @ereichert @bronzdoc !

Should it only scan .md files regardless if other files are present?

Yes, because they're the source text, other things are generated from them.

Do you want the program in a new repo or part of this repo?

In this one would be cool!

@ereichert

This comment has been minimized.

Show comment
Hide comment
@ereichert

ereichert Aug 6, 2016

Contributor

If someone doesn't get it done before tonight I'll get on it.

Contributor

ereichert commented Aug 6, 2016

If someone doesn't get it done before tonight I'll get on it.

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Aug 6, 2016

Member

I'm not going to "reserve" this for anyone-- please don't worry about duplicating work, especially if you're doing this for learning! ❤️ Or perhaps collaborate!

We also might have more little things like this in the future!

Member

carols10cents commented Aug 6, 2016

I'm not going to "reserve" this for anyone-- please don't worry about duplicating work, especially if you're doing this for learning! ❤️ Or perhaps collaborate!

We also might have more little things like this in the future!

@ereichert

This comment has been minimized.

Show comment
Hide comment
@ereichert

ereichert Aug 6, 2016

Contributor

@bronzdoc if you want to write it I'd be happy to mentor.

Contributor

ereichert commented Aug 6, 2016

@bronzdoc if you want to write it I'd be happy to mentor.

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Aug 6, 2016

Member

We also might have more little things like this in the future!

Agreed. There's probably a lot of little things that would be cool to lint.

Member

steveklabnik commented Aug 6, 2016

We also might have more little things like this in the future!

Agreed. There's probably a lot of little things that would be cool to lint.

@bronzdoc

This comment has been minimized.

Show comment
Hide comment
@bronzdoc

bronzdoc Aug 6, 2016

That would be awesome @ereichert thank you.

bronzdoc commented Aug 6, 2016

That would be awesome @ereichert thank you.

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Aug 15, 2016

Member

Oops this didn't get closed!! This was fixed in #177 :)

Member

carols10cents commented Aug 15, 2016

Oops this didn't get closed!! This was fixed in #177 :)

@helpingothers4u2

This comment has been minimized.

Show comment
Hide comment
@helpingothers4u2

helpingothers4u2 Jun 12, 2018

On helping others that's the year I started my page on Facebook helping others.

On helping others that's the year I started my page on Facebook helping others.

@czeronigeria

This comment has been minimized.

Show comment
Hide comment
@czeronigeria

czeronigeria Jul 6, 2018

@ereichert please i am new to github aspering frontend web developer would need mentorship still learning on udacity

@ereichert please i am new to github aspering frontend web developer would need mentorship still learning on udacity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment