VS Code ruby-rubocode increase Metrics/MethodLength check - visual-studio-code

Rubocode (in VS Code's ruby-rubocode extension) insists that no method should be longer than 10 lines:
Metrics/MethodLength: Method has too many lines. [11/10] (convention:Metrics/MethodLength)
I think that this is a bit severe, and would like to change it to 20.
Is it possible to edit this value via VS Code's settings.json?
Update
B) Is it also possible to increase the Metrics/LineLength from 80 to 120?
Metrics/LineLength: Line is too long. [108/80] (convention:Metrics/LineLength)

You can edit rubocop config/default.yml to do what you are looking for.
Look at the Metrics section and change Metrics/LineLength and Metrics/MethodLength values.
If you want to change these settings for your current project only then create .rubocop.yml file in the required project directory:
Metrics/LineLength:
Max: 120
Metrics/MethodLength:
Max: 20

Related

How can I control my build number with Azure DevOps?

I get so many frustrations with Azure DevOps. In my Build number format I would like to have both
A number that restart to 0 when I update my major an minor version.
But I also would like to have a real build number that is never reset whatever is my build number format. This build number can also be shared by all my build pipeline of my project. Is it possible?
I'm not using YAML format. I use the classic interfaces with the option page to set my build format. At this moment I have this:
It work except each month the r number restart at 0. I want it to continue.
EDIT
I still didn't decided my final format. I would like to understand all the possibilities. Now I discovered the $(BuildID) property I have another question. Is it possible to have something similar to $(Rev:r) variable but that only check the left part of my build number.
Example:
4.16.$(SequenceFor[4.16]).$(BuildID)
In fact I would like to manually set the Major and Minor version and let the system update one by one the Build and use the Revision for the global $(BuildID).
The $(rev:r) is restarted when the build number changes in any character, so this is the reason why it's restarted whenever the major/minor or the sate changed.
So if you want to use an incremental unique number you can't use the $(rev:r) because then it will be restarted each build.
If you want a number that depends on the major and the minor numbers you need to use the counter expression:
Create 2 variables:
major-minor = 4.16
And a variable that depends on his value and also is a counter:
revision = $[ counter(variables['major-minor'],0) ]
The build number will be:
$(major-minor).$(revision).$(Build.BuildId)
Now, if you will change the major-minor (to 4.17 or 5.16) the revision will be again 0.

Change configuration options for specific files only

I'm working on a small part of a huge project. I need to change some Doxygen configuration options only for specific files. For example, there is such configuration option DOT_GRAPH_MAX_NODES and its default value is 50. I need to increase its value to 100 but only for some source files (for all other source files it should be 50). What is the the best way to achieve it?
I'm a newbie in Doxygen and I tried to #include my configuration file on a top of .cpp or try to set a new value to an option there as well but it did not help (but did not cause any warnings or errors):
/// #include MyDoxyfile
// or
/// DOT_GRAPH_MAX_NODES = 10000
I appreciate any help.
In doxygen the DOT_GRAPH_MAX_NODES is a global setting and cannot be altered. This contrary to some graphs that can be shown / hidden:
• if CALL_GRAPH is set to YES, a graphical call graph is drawn for
each function showing the functions that the function directly or
indirectly calls (see also section \callgraph and section
\hidecallgraph).
• if CALLER_GRAPH is set to YES, a graphical caller
graph is drawn for each function showing the functions that the
function is directly or indirectly called by (see also section
\callergraph and section \hidecallergraph).
and in the upcoming 1.8.15 version a similar mechanism is implemented for
REFERENCED_BY_RELATION, commands: showrefby and hiderefby
REFERENCES_RELATION, commands: showrefs and hiderefs

javascript turn off code formatting

vscode is great, but it oversteps boundaries. I'd like to maintain my coding style but seem to be constantly forced into some invisible 'standard', defined by MSoft, I suppose. At any rate, I have "javascript.format.enable": false set and yet it still insists on changing my code.
Take something simple, like dothis(y+2), gets converted to dothis(y + 2) on Save (Ctrl-S). There are many times when I just want what I typed in. How can I get vscode to help me out instead of imposing its own 'standard'?
Do you have "editor.formatOnSave": true in user settings or folder settings? Or, an extension installed that may be doing this?

Variable code coverage threshold with sbt-scoverage

I'm using sbt-scoverage plugin for measure the code (statement) coverage in our project. Because of months of not worriying about the coverage and our tests we decided to set a threshold for having a minimum coverage percentage: if you are writing code at least try to leave the project with the same coverage percentage as when you've find it. e.g. if you've started your feature branch with a project having 63% of coverage you have, after finishing your feature, to leave the same coverage value.
With this we want to ensure a gradual adoption of better practices instead of setting a fixed coverage value (something like coverageMinimum := XX).
Having said that, I'm considering the possibility of storing the last value of the analysis in a file and then compare that with a new execution, triggered by the developer.
Another option that I'm considering is to retrieve this value from our SonarQube server based on the data stored there.
My question is: Is there a way to do a thing like this with sbt-scoverage? I've dug into the docs and their Google Groups forum but I can't find something about it.
Thanks in advance!
coverageMinimum setting value doesn't have to be constant, you can write any function dynamically returning it, eg:
coverageMinimum := {
val tmp = 2 + 4
10 * tmp // returns 60 :)
}

phpThumb is not setting parameter – fltr[] usm

I am using Brett's Mr. PHP thumb caching script along with phpThumb to create my thumbs. It works extremely well, except for one thing... I cannot get it to set and process the UnSharpMask filter. The relevant part of the script looks like this:
// generate the thumbnail
require('../phpthumb/phpthumb.class.php');
$phpThumb = new phpThumb();
$phpThumb->setSourceFilename($image);
$phpThumb->setParameter('w',$width);
$phpThumb->setParameter('h',$height);
$phpThumb->setParameter('q','95'); // set the quality to 95%
$phpThumb->setParameter('fltr[]','usm|80|0.5|3'); // <--- THIS SHOULD SET THE USM FILTER
$phpThumb->setParameter('f',substr($thumb,-3,3)); // set the output file format
if (!$phpThumb->GenerateThumbnail()) {
error('cannot generate thumbnail');
}
I'm guessing there's a problem with my syntax, since the fltr[] parameter requires brackets. I have tried escaping the brackets like so: 'fltr[]' but that didn't work either.
I've used several other possible parameters with good success (zoom cropping, max height, max width, etc...) Everything seems to work except the filters (including usm - UnSharpMask).
I don't get any errors. It spits out thumbs all day long. They're just not sharpened.
For reference, here's the official phpThumb readme file that discusses all the possible settings and filters.
Thanks for looking.
Well after much trial, error, and aggravation, I finally discovered the solution buried in one of the demo files that come with phpThumb.
It's a matter of removing the brackets all together. Basically changing this line:
$phpThumb->setParameter('fltr[]','usm|80|0.5|3');
to this:
$phpThumb->setParameter('fltr','usm|80|0.5|3');
After that, it's only a matter of tweaking the settings to get the desired amount of sharpness.