Giter Club home page Giter Club logo

youshouldspellcheck.analyzer's People

Contributors

brightlight avatar steffen-wilke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

youshouldspellcheck.analyzer's Issues

Differentiate between "identifiers" and "normal text"

We have to differentiate between "identifiers" and "normal text", as totally different rules apply:

  • Identifiers cannot have whitespaces between words. Instead, they use casing to separate words.
  • in contrast, normal text uses whitespaces to separate words
  • normal text must support abbreviations, which sometimes themselves may contain whitespaces (ideally non-breaking space)
  • normal text might contain GUIDs (e.g. in certain arguments)
  • normal text might contain certain annotations like "ToDo xy/dd.mm.yyyy" which should not raise issues
  • word recognition might be tricky, e.g. "Delivery-planned/actual"
  • identifiers can contain numbers, e.g. "Information3"

Support "/" as word separator

If text contains "/" without spaces, like costs/revenues, it is treated as one word, in consequence often flagged as an issue and suggestions show up.

Check of literal strings in code and attributes should be separate code inspections

I would like the possibility to only check attribute properties at first (to reduce false-positives if code is not prepared for a spellchecker). Therefore it should be possible to enable code inspections for attributes without also enabling code inspections for all other string literals as well.
At the moment, both are controlled by YS101.

Provide nuget package

For easier usage there should be a nuget package to add this analyzer to projects.

Add documentation

This analyzer has now reached beta stage. I can experimentally use it at work for "real-life" testing, but there is no documentation yet regarding how to add/use this analyzer, about the format of the XML configuration file, how to add the configuration file to projects ("AdditionalFiles"), etc.

Option to exclude certain "things" from checks

The configuration should allow to exclude certain types or even whole namespaces from the checks.
Using some sort of wildcard or regex would probably be the most flexible way to do this.

Examples:

  • Exclude namespace
    Company.Department.Area
  • Exclude namespace and beneath
    Company.Department.Area.*
  • Exclude one type
    Company.Department.Area.TypeName.*
  • Exclude one method in one component
    Company.Department.Area.TypeName.MethodeName.*

But how to exclude only the check of attributes or certain types of attributes and not also the check of identifiers?

Support rule and language definition on sub-attribute level

It must be possible to define language even on sub-attribute level. For instance, certain attribute arguments represent normal text (e.g. "Caption", "Description") while other arguments reference identifiers (e.g. resource strings) and therefore must be spellchecked using identifier rules (or not be checked at all, because the referenced identifier will be checked anyway).
Also, normal text (like "Caption" and "Description") might require a different language than identifiers.

Reorder code inspection identifications

In the current state, there is an extra rule-id per identifier type. Each rule (code inspection) can be enabled separately. Also, the valid language(s) can be set for each identifier type separately.
I can't imagine a situation where it would make sense to use a different language for classes and methods, or methods and events, etc. So maybe the configuration should be simplified.

Regarding the rule identifications: my suggestion would be this:

  • digit 1 identifies the used "engine":
    • 1: Hunspell (local dictionary)
    • 2: LanguageTool
  • digit 2-3 identify the item type that is checked
    • 01: string literal
    • 02: XML comment
    • 03: identifier (can be split into more detail if necessary later)
  • digit 4-5 identify the type of finding. Depends on used engine (see digit 1)
    • HUnspell: always 00 ("general", Hunspell, doesn't support categories)
    • LanguageTool: some sort of category-id mapping

Suggestions offered for identifiers should produce valid identifiers

The suggestions shown for a flagged identifier (or part of it) ar exactly the ones that the spellchecker provided. This means that sometimes compound words, or words with spaces are suggested.
For instance, "ShowPopupMenu" will suggest "pop-up" and "pop up" as replacements for "Popup".

NullReferenceException executing code fixes (seems new in VS 16.8.x)

I get a NullReferenceException when an issue is shown and I want to open the available code fixes ("suggestions") in the context menu. I have not changed the analyzer for at least months. Only thing that has changed is that I have updated my Visual Studio 2019.

System.NullReferenceException : Object reference not set to an instance of an object.
   at YouShouldSpellcheck.Analyzer.YouShouldSpellcheckAnalyzerCodeFixProvider.Suggestions(String word,IEnumerable`1 languages,Dictionary`2 allSuggestions)
   at YouShouldSpellcheck.Analyzer.YouShouldSpellcheckAnalyzerCodeFixProvider.Suggestions(Diagnostic diagnostic,String& offendingWord,Dictionary`2 allSuggestions,IEnumerable`1 languages)
   at async YouShouldSpellcheck.Analyzer.TextCodeFixProvider.RegisterCodeFixesAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)

TextCodeFixProvider

Take escape characters into account when reporting issues

Currently, squiggly lines sometimes appear slightly off. This is the case when the string contains escape characters, for instance for quotes (\"). Verbatim strings can also contain such escape characters (example: @"This is a ""quote""").

    [Display(Name = "Special \"escapng\" and \na new lines")]
    public string Name3 { get; }

Consider code styles

For instance, for public const string XmlVersion = "Version"; I get the suggestion to replace "Xml" with "XML". That suggestion is fine for literal strings or XML comments, but my code styles require pacal casing for identifiers, so XmlVersion is correct and XMLVersion would be wrong (and trigger other issues).

Check multi-line XML comments as one

Multi-line XML comments are currently checked line-by-line separately. That's okay if you just do a spellcheck. But it's not optimal for a grammar check (LanguageTool).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.