I have a go linter in a .golangci.yml file for my workspace. As of now, I have disabled lints in test files since there are simply too many checks:
run:
tests: false
# rest of run configs ...
issues:
# all run issues
However, I want to enable lint checks only on new test files, or new diffs. Any existing linting errors should be ignored.
I tried modifying the yml file using a new : true parameter under issues:
run:
tests: false
# rest of run configs ...
issues:
new : true
# all run issues
However, the linter still checks all test files for listing, including the previous problems.
I tried switching the order and also replacing new : true with max-same-issues : 0.
I was in particular following this guide: https://golangci-lint.run/usage/configuration/.
It's also worth noting that the SVC is Perforce, not Git.
Related
Normally Ruby test-unit will display a summary of tests run after they are finished, something like this:
Finished in 0.117158443 seconds.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
10 tests, 10 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
298.74 tests/s, 0.00 assertions/s
This was working, but now something has changed and when the unit tests are run it shows the dots but then stops. I tried re-organizing some test file into different directories and made absolutely sure to change the filepaths in the testrunner. Also, the dots do not match the number of tests/assertions.
Loaded suite test
Started
.................$prompt> // <<-- does not put newline here.
I notice that if I run the testrunner from another directory, the summary will show, but it will cause errors with the test dependencies. I should be able to run the testrunner from the same directory. This is an example of the testrunner I am using: https://test-unit.github.io/test-unit/en/file.how-to.html. What are the reasons that this would not display at the end?
Seems like it could be an issue with not having the test-unit.yml file in the same directory as which you run the script.
See here in the code or in the same section in that document you posted.
See how it's configured here, for example:
runner: console
console_options:
color_scheme: inverted
color_schemes:
inverted:
success:
name: red
bold: true
failure:
name: green
bold: true
This part of the code documentation really stuck out:
# ## Test Runners
#
# So, now you have this great test class, but you still
# need a way to run it and view any failures that occur
# during the run. There are some test runner; console test
# runner, GTK+ test runner and so on. The console test
# runner is automatically invoked for you if you require
# 'test/unit' and simply run the file. To use another
# runner simply set default test runner ID to
# Test::Unit::AutoRunner:
Maybe you need to have that runner specified in your YML file?
Without seeing how you are calling your script and your directory organization, it will be hard to tell what is causing that issue but I think it begins with it not reading that yaml file for instance.
If all else fails, let me recommend two great unit testing libraries for Ruby if you feel compelled to switch to a more widely-used library:
minitest
RSpec
Edit: You could also revert your directories to be in the same order as before and hardcode in your Gemfile for that test-unit gem the last version that worked for you, like `"test-unit": "3.4.0".
Looking at this post (Cypress - How can I run test files in order), I have several scripts specified under testFiles in cypress.json but opening Cypress with npm run cypress still shows all of the scripts in my repo and nothing happens.
Is there a way/trick to (a) automatically running the files specified in cypress.json in the UI and (b) a way to "toggle back" to all of the files in the repo (because I have some scratch files I use to isolate test features and additional tests that will eventually be added to the list)
The section from my cypress.json looks like
"testFiles:" :[
"/venueadmin/events/venueAdminCreateEvent.spec.js",
"/renter/renterInvalidLogin.spec.js",
"/renter/renterSignUp.spec.js"
]
etc.
Figured it out. There's a duplicate :
Also, if there's a slash pre-pended on the script name that needs to be removed
"testFiles" :[
"venueadmin/events/venueAdminCreateEvent.spec.js",
"renter/renterInvalidLogin.spec.js",
"renter/renterSignUp.spec.js",
I'm adding a linter for gosec for golangci-lint and everything is covered except the following:
exec.Command(params[0], params[1:]…)
I know that I can disable this lint but I don't want to do it. Is there a way to fix the code to satisfy this lint?
the error is:
G204: Subprocess launched with function call as argument or cmd arguments ```
Instead of disabling the linter you could exclude the specific line with an annotation;
exec.Command(params[0], params[1:]...) //nolint:gosec
If you want to disable only this check, you can
exec.Command(params[0], params[1:]...) // #nosec G204
Hardcode a command call. There are no other options AFAIS.
Update: starting from version 1.40 you gosec options are customizable, see example config .golangci.example.yml in https://github.com/golangci/golangci-lint repository.
linters-settings:
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
includes:
- G401
- G306
- G101
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
excludes:
- G204
# To specify the configuration of rules.
# The configuration of rules is not fully documented by gosec:
# https://github.com/securego/gosec#configuration
# https://github.com/securego/gosec/blob/569328eade2ccbad4ce2d0f21ee158ab5356a5cf/rules/rulelist.go#L60-L102
config:
G306: "0600"
G101:
pattern: "(?i)example"
ignore_entropy: false
entropy_threshold: "80.0"
per_char_threshold: "3.0"
truncate: "32"
The Setup:
Using scss-lint plugin for IntelliJ-based IDEs (PHPStorm)
http://plugins.jetbrains.com/plugin/7530?pr=phpStorm
A gulp-compass task, part of a larger Gulp build process, that watches my sass (scss) dir.
https://www.npmjs.com/package/gulp-compass
NOTE:
OS: Windows 8
both tools work as expected.
The Situation:
With the scss-lint inspection active, any kind of typing activity in the editor (including simply typing a whitespace) triggers the gulp-compass task, and the terminal for said task returns 'file not found' errors along the following line:
[10:53:34] Starting 'dev-compass'...
[10:53:34] Finished 'dev-compass' after 3.58 ms
[10:53:36] File not found: E:/projects/xf/src/sass/blog_scsslint_tmp8349313806557714816.scss
[10:53:36]
[10:53:36] { [Error: Compass failed]
message: 'Compass failed',
showStack: false,
showProperties: true,
plugin: 'gulp-compass',
__safety: { toString: [Function] } }
[BS] 1 file changed (blog.css)
[10:53:46] Starting 'dev-compass'...
[10:53:46] Finished 'dev-compass' after 15 ms
write src/styles.group/blog.css
[BS] 1 file changed (blog.css)
Note: this 'error' doesn't prevent the task to perform; when I make actual changes to the .scss source files, the .css are generated properly.
Apparently, either SCSS Lint itself and/or the PHPStorm plugin generate temporary files when the inspection occurs, and promptly removes them -- presumably when the inspection finishes.
As it does so in the same directory that's being watched by the gulp-compass task... These two end up playing NYSMNYD (now you see me, now you don't).
I was hoping I could either:
set my SCSS Lint configuration file to force a different path for the temporary files, or,
set my gulp-compass task to ignore files based on a pattern such as *scsslint_tmp*.scss
But so far, I haven't found any way to do either of these.
I suppose it could be seen as just a 'cosmetic' error, since both tools do produce the desired outputs, but it results in unnecessary processing, and by filling my terminal with 'bogus' errors just make it more confusing to spot the genuine ones.
Any ideas?
I'm using Jekyll Asset Pipeline to build my website and I'd like to only compress the website (which takes about 20 seconds) when I'm publishing it. To do this I have to enable these values programmatically in the config file:
asset_pipeline:
bundle: false
compress: false
I've tried to code a plugin but it isn't working. Could someone help me as to why?
module Jekyll
module Commands
# I overwrite this here so we only do heavy work (like compressing HTML and stuff)
# when we are building the site, not when testing (which uses jekyll serve)
class << Build
alias_method :_process, :process
def process(options)
require 'jekyll-press'
options['asset_pipeline']['bundle'] = true
options['asset_pipeline']['compress'] = true
_process(options)
end
end
end
end
You don't even need a special gem - you can pass multiple configuration files to jekyll build:
First, the regular config file, with all the settings that are always needed, plus the values to disable compressing, since you don't always want it to run each time you're building locally:
_config.yml:
destination: _site
source: src
markdown: rdiscount
# ... and many more settings that are always needed
asset_pipeline:
bundle: false
compress: false
Then, you need a second config file for publishing which overrides only the values that you actually want to be different:
_config-publish.yml:
asset_pipeline:
bundle: true
compress: true
So when you're not publishing, you just run jekyll build like before.
But when you're publishing, you pass both config files in the right order:
jekyll build --config _config.yml,_config-publish.yml
Jekyll will apply them in the order you passed them, so the settings in the second file will overwrite the ones in the first file, and bundle and compress will be set to true in the end.
In case you can't control what parameters will be passed to jekyll build (maybe on GitHub Pages? I never used it, but maybe...) you can do the same thing, just the other way round:
Set bundle and compress to true in the default config file
Whenever you're not publishing, use a second _config-dev.yml file to set bundle and compress to false again
The gueard-jekyll-plus gem allows you to configure multiple configuration files where the later ones override the former ones. I have the same set up where I have a _development.yml file that turns off all the asset compilation settings for development work. Yes you have to set guard up, but it makes it simple to refresh the site. Here's the relevant section:
guard 'jekyll-plus', extensions: %w[slim yml scss js md html xml txt rb], serve: true, rack_config: 'config.ru', config: ['_config.yml', '_development.yml'] do
watch /.*/
ignore /^build/
end
I detail most of the basic setup in of the Gem in the article Integrate Jekyll with Slim, Zurb Foundation, Compass and an Asset Pipeline.
Couldn't you also just do:
> jekyll build --config _development.yml
To build with a different configuration file?