I have been using linters in NodeJS for a while eslint and have started using cpplint on my Arduino libraries in C++. It does not seem to pick up some fundamentals such as missing semicolons (but it does identify braces on the wrong line). It also doesn't seem to differentiate between spaces and tabs for indentation or badly indented code in the implementation file.
Coming from a NodeJS background, cpplint seems to be missing a lot of checks or am I completely missing the point?
cpplint only checks code style based on Google C++ Style Guide. As long as I know, it won't check syntax error. If we look on cpplint.py implementation, we won't found any rule of regex govern about missing semicolons. And about indentation, as long as the whitespace width is even and not tabs, cpplint will pass it.
Related
I have no idea what on earth has happened to my VSCode. I am unable to trace which or exactly what extension caused this. But, the C++ syntax coloring and theme looks absolutely ugly.
I want this,
How can I get that back? I am unable to figure this out. I uninstalled all C/C++ extensions and still the issue remains.
VSCode colorizes brackets and parentheses to make it easier to see which opening bracket belongs to which closing bracket.
You can turn it off in the settings:
I am trying to get the Jenkins Warnings Next Generation plugin to be able to parse warning messages that span multiple lines but unfortunately the plugin only matches one line and cannot do multiline?
In the configuration for the plugin, there is a feature where it shows a preview when you try out your regular expression. In the preview, it seems to work fine and catches my example warning but when it tries to parse through the console output for warnings, it fails to catchy any (all my warnings span multiple lines).
Not exactly sure why it's not working in the real output but is working in the preview. The plugin is able to catch multiple warnings if the match is only 1 line.
You can see what I have done here:
https://regexr.com/4o3lq
I am currently using this for regular expression to input into the plugin configuration
(?ms)\x08(.*?)\x08
The warning is encapsulated by the \x08 special character (see regexr).
I thought that the mode modifier (m and s) would allow multiline but apparently not.
Thanks in advance!
Was able to resolve my issue.
The Jenkins warnings parser preview is a bit misleading since I thought the previous Regex would be good enough to catch multiple line warnings but apparently the \r needs to be included. Within the plugin source code, there is a check that sees if a \r or \n is included in the Regular Expression and if there is, the Groovy Parser plugin will enable multiline support.
(?ms)\x08(.*?)\r?\x08
May or may not need the "m" in the mode modifier.
How do I optimize this to find all links ending in weird typos, yet still exclude correct links (ending with .html) from the results?
htmll$|hhtml$|httml$|htmml$|htmll$|btml$|hml$|htl$
Thanks in advance!
Wow, that's some pretty restrictive regex rules but that kinda makes it interesting.
since we have no character negation but we do have character classes we could do:
[a-gi-z]tml$|h[a-su-z]ml|ht[a-ln-z]l|htm[a-km-z]
for my second suggestion and:
h.+tml|ht.+ml|htm.+l|html.+
to replace the first option leading to a total of:
[a-gi-z]tml$|h[a-su-z]ml|ht[a-ln-z]l|htm[a-km-z]|h.+tml|ht.+ml|htm.+l|html.+
EDIT: Having noticed that the .+'s can catch things we don't want this should be changed slightly.
(.*[a-gi-z]tml|h.*[a-su-z]ml|ht.*[a-ln-z]l|htm.*[a-km-z])$
Today I got an email from my boss saying to change the regex in our java script code that goes onto our client's website from
[a-zA-Z0-9]+[a-zA-Z0-9_\.\-]
to
[a-zA-Z0-9]+[a-zA-Z0-9_\-\.]
because one of our clients were complaining that it wasn't regex best practices and it's causing problems with their CMS and their DB.
Looking at those two regexes, It appears to me they match the exact same thing.
the . and the - are swapped at the end, but that shouldn't make a difference. Should it?
Am I missing something?
The developer from our client's company is really adamant about us changing it.
Can someone shed some light?
Thanks!
There is no functional difference.
If anything is having issues with that regex, then it is a non-standard/buggy implementation. I recommend finding out exactly what the problem is.
While I see no reason to change it, I see no reason not to change it, so do what you wish.
Tip: I'm guessing the regex is written wrong. If I know what it is supposed to mean, I would write it:
[a-zA-Z0-9]+[_\.\-]?
If you use a - in a character group, it goes last otherwise it denotes a range of characters, like A-Z. If you're escaping it, like you are, then it can be anywhere.
It's possible the CMS or other code they use un-escapes the regex, so in this case it will throw errors if the - isn't the last character in the group. I would say that having as few escaped characters in a regular expression as possible makes it easier to read, but that's from a personal perspective.
I have a horribly formated, tab delimited, "CSV" that I'm trying to clean up.
I would like to quote all the fields; currently only some of them are. I'm trying to go through, tab by tab, and add quotes if necessary.
This RegEx will give me all the tabs.
\t
This RegEx will give me the tabs that do not END with a ".
\t(?!")
How do I get the tabs that do not start with a "?
Generally for these kinds of problems, if it's a one time occurrence, I will use Excels capabilities or other applications (SSIS? T-SQL?) to produce the desired output.
A general purpose regex will usually run into bizarre exceptions and getting it just right will often take longer and is prone to missed groups your regex didn't catch.
If this is going to happen regularly, try to fix the problem at the source and/or create a special utility program to do it.
Use negative lookbehind: (?<!")\t
For one shots like this I usually just write a little program to clean up the data, that way I also can add some validation to make sure it really has converted properly after the run. I have nothing against regex but often in my case it takes longer for me figure out the regex expression than writing a small program. :)
edit: come to think about it, the main motivator is that it is more fun - for me at least :)