Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple specification style checker #799

Closed
11 tasks done
treiher opened this issue Oct 6, 2021 · 1 comment · Fixed by #826
Closed
11 tasks done

Simple specification style checker #799

treiher opened this issue Oct 6, 2021 · 1 comment · Fixed by #826
Assignees
Labels
small Effort of one person-day or less specification Related to specification package (e.g., specification parsing)

Comments

@treiher
Copy link
Collaborator

treiher commented Oct 6, 2021

A simple specification style checker based on regular expressions could ensure:

  • Indentation level is multiple of three spaces
  • Consistent comment formatting
    • Arbitrary amount of spaces between start of line and --
    • One space between non-space tokens and --
    • Always at least one space after --
  • No DOS line terminators
  • No form feeds, horizontal or vertical tabs
  • No blanks at end of line
  • No double blanks
  • No double blank lines
  • No blank lines at beginning or end of file
  • Maximum line length
  • Token spacing (A + B vs. A+B)
  • Keyword indentation (e.g., 6 spaces before message)

Options for handling of style errors:

  1. Just print warning.
  2. Print warning, continue, but return non-zero value.
  3. Print error and stop.
  4. Make behavior configurable.

=> Option 3 - always treat as errors.

@treiher treiher added specification Related to specification package (e.g., specification parsing) small Effort of one person-day or less labels Oct 6, 2021
@treiher treiher added this to To do in RecordFlux 0.6 via automation Oct 6, 2021
@treiher treiher moved this from To do to In progress in RecordFlux 0.6 Oct 14, 2021
@treiher treiher self-assigned this Oct 14, 2021
@treiher
Copy link
Collaborator Author

treiher commented Oct 20, 2021

There are conflicts with the planned checks, which are not that simple to solve.

Indentation level is multiple of three spaces

Cannot be applied for multiline constructs.

   type E is
      (A => 1,
       B => 2,
       C => 3)
   with Size => 8;
            if Message'Valid = False
               or (Message.Tag = A
                   and Message.Length = 0)
         Response := Create_Message (Tag,                                                                 
                                     Message.Data);
      with function Create_Message
         (Tag : E;
          Value : Opaque)
      return M;

No double blanks

Prevents alignment of arrow in enumerations.

   type E is
      (A   =>   1,
       AB  =>  12,
       ABC => 123)
   with Size => 8;

No double blanks and token spacing

The style rules should not apply in strings.

         X := Fun (Y, "Foo  Bar+Baz");

treiher added a commit that referenced this issue Oct 21, 2021
@treiher treiher moved this from In progress to Under review in RecordFlux 0.6 Oct 21, 2021
treiher added a commit that referenced this issue Oct 21, 2021
treiher added a commit that referenced this issue Oct 21, 2021
treiher added a commit that referenced this issue Oct 22, 2021
treiher added a commit that referenced this issue Oct 22, 2021
RecordFlux 0.6 automation moved this from Under review to Merged Oct 22, 2021
treiher added a commit that referenced this issue Oct 22, 2021
treiher added a commit that referenced this issue Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
small Effort of one person-day or less specification Related to specification package (e.g., specification parsing)
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant