I would like to force 4 spaces as the default and required indentation for my whole js codebase.
I have managed to the jshint wro4j plugin to work and obey options:
<options>browser,newcap,noarg,nonew,undef,trailing</options>
However, for indentation, I need to specify the spaces required:
/*jshint indent:4 */
but there appears to be no facility to do this?
I'm not sure how I should be applying this option correctly as any of the layouts I've tried throw errors as being invalid options.
You can force the indentation rule check by adding the following rules:
<option>indent,white</option>
By default the indentation is set to 4 characters. If you want to set a different value, use this:
<option>indent=2,white</option>
Related
I'm trying to define custom format rules, and for some reason clang-format reverts to the default rules, despite my file having no discernable mistakes.
More precisely, I'm trying to define use detailed rules for AlignConsecutiveDeclarations. This .clang-format file works :
AlignConsecutiveDeclarations: true
UseTab: "Always"
IndentWidth: 4
TabWidth: 4
And this one, which should give the exact same result, breaks and reverts to default format :
AlignConsecutiveDeclarations:
Enabled: true
UseTab: "Always"
IndentWidth: 4
TabWidth: 4
Am I doing something wrong ? Or is the extension broken ? My file seems completely valid to me, but I very well could be wrong. Also please note this is a deliberately reduced example, even when specifying more options, the rule still breaks the entire file.
I'm using VSCodium 1.75.0 on macOS 13.2.1, with the clangd extension version 0.1.23 ; as far as I have checked those are the latest versions of everything.
Looking at clangd's output in the console, this is what it says about the affected rule :
/Users/crysambrosia/Developer/Project/.clang-format:2:2: error: unknown enumerated scalar
Enabled: true
This changes to whatever the first variable is, no matter which one it is.
This option is available in clang-format 15. You seem to use the older clang-format. It's unclear from your question what clang-format do you uses. VSCode, macOS, clangd all their versions are unrelated to clang-format. Compare https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html and https://releases.llvm.org/15.0.0/tools/clang/docs/ClangFormatStyleOptions.html in two browser tabs. You will see the difference.
I have a Ruby code base which has been maintained for many years. When I use RuboCop to check the code-style, it will give me thousands of offenses. Is there a way use RuboCop to check only the new added code or new modified code, and only report offenses for that code?
There are a couple of ways in which Rubocop can help you.
If you run
rubocop --auto-gen-config
Rubocop will generate two configuration files for you: a mostly empty .rubocop.yml, which only contains one key:
inherit_from: .rubocop_todo.yml
And a .rubocop_todo.yml which disables every offense found in your codebase on a per-file basis:
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-09-11 06:20:56 UTC using RuboCop version 0.90.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Cop supports --auto-correct.
Layout/SpaceAfterMethodName:
Exclude:
- 'test.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'test.rb'
This file is used for two things:
If your organization's style guide differs from the default Rubocop config, you can cut&paste the offense from the TODO into the "real" config file and disable it permanently and globally.
You can use the TODO file as an actual TODO list, and remove the exclusions one-by-one and fix the offenses one-by-one whenever you have time to do them.
Note, however, that exclusions are file-based, not line-based, so you can only disable cops globally or per-file. When you make changes to an existing file, your newly added code will also have those cops disabled, so it is a good idea to enable linting of the file first and fix all existing offenses.
Also note that you will probably have to use the --exclude-limit COUNT option, because if there are more than COUNT files with the same offense, Rubocop will just disable it globally. The default is 15, so you should set it to a value that is higher than the total number of files in your project.
Another helpful parameter is
rubocop --safe-auto-correct --disable-uncorrectable
Which will safely auto correct all safely auto correctable offenses, and add comments to disable cops for non-correctable offenses.
However, I would argue that this is not actually Rubocop's job in the first place. Your reporting system should have a way of recording a "baseline", and only report deviations from that baseline.
I found that pronto-rubocop may do the job
Instead of excluding or ignore rules in sonar's property file, I'd like to have only a few certain rules for sonar to analyse, so I don't need to exclude a large number of rules out of 344 rules for c++. How can I do that? (I'm not adding customized rules)
I imageine the syntax would be: (in .properties file)
sonar.issue.include.multicriteria=***
sonar.issue.include.multicriteria.***.ruleKey=cpp:S984
....
EDIT:
1, I need to configure this in a CLI environment.
2, It's about one project, two rule sets. one rule sets for local use and the other one for CI/CD use.
You need to craft a Quality Profile that contains only your rules of interest, and then either make it the default profile for C++, or explicitly assign your project to it.
BTW, correctly setting exclusions in properties (versus through the UI) is quite tricky. I'm not sure about the correctness of the ruleKey field name, and you're probably missing another field in there, but your syntax seems to be on the right track.
I wish to change the rule 'Left curly braces should be located at the end of lines of code' since we are using a different convention.
Thanks in advance!
As Sonarqube intends to provide the least possible configuration possible on rules: you should deactivate the rule with key squid:LeftCurlyBraceEndLineCheck and I am guessing that you want to activate the rule : squid:LeftCurlyBraceStartLineCheck
Please note that those rules have nothing to do with Checkstyle.
How can I force CKEditor to automatically convert special Characters to HTML Numbers?
For example when I write 6% in the editor and then look at the source code I get <p>6%</p> but what I want to get in the source is <p>6%</p>
Is this possible?
Thanks
Check this option config.entities and all other entities_* options. Using them, you can configure editor to produce entities only for nbsp, gt, lt and amp. It is also possible to switch that off (check config.basicEntities), but it may causes issues as noted in docs.
CKEDITOR.config.entities_additional = '#36,#37'; //$,%
Please, check too:
CKEDITOR.config.entities_processNumerical = 'force';