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

Extend cops meta data #6293

Merged
merged 2 commits into from Sep 26, 2018

Conversation

Projects
None yet
3 participants
@Darhazer
Copy link
Member

Darhazer commented Sep 14, 2018

  • Merged default.yml, enabled.yml, and disabled.yml into single config
  • Added version added/changed/removed for all cops since 0.5 (428/428 cops)

TODO:

  • Update documentation generating script to include meta info
  • Add Safe & SafeAutocorrect meta-data (currently 6 cops are marked unsafe, 10 with unsafe autocorrect, probably needs more work)
  • Add version meta data for older releases
  • Update OBSOLETE_COPS checks to check VersionRemoved meta data We don't have VersionRemoved in this release, this should be a follow up for 1.0
  • Update manual/configuration.md
  • Review EnabledByDefault/DisabledByDefault option

I wonder what should we do with removed cops? Add them in a separate config? Leave them in default.yml in alphabetical order? Just remove them and start providing the VersionRemoved from 1.0 onwards?

Currently they are in a separate file, not required in default.yml, as otherwise config loader breaks.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run rake default. It executes all tests and RuboCop for itself, and generates the documentation.
@bbatsov

This comment has been minimized.

Copy link
Collaborator

bbatsov commented Sep 15, 2018

I wonder what should we do with removed cops? Add them in a separate config? Leave them in default.yml in alphabetical order? Just remove them and start providing the VersionRemoved from 1.0 onwards?

I think we should remove them and start providing VersionRemoved after your PR is merged for cops deleted in the future.

My plan for them down the road is to just leave dummy classes in place, so we can keep the cops in the default file and don't need any special handling for them.

@bbatsov

This comment has been minimized.

Copy link
Collaborator

bbatsov commented Sep 15, 2018

P.S. Great progress, btw! The PR is shaping up pretty well!

@Darhazer Darhazer force-pushed the cops-meta-data branch 2 times, most recently from 12c6fdf to 7c75875 Sep 15, 2018

@Darhazer

This comment has been minimized.

Copy link
Member Author

Darhazer commented Sep 21, 2018

I processed all cops down to version 0.5 - seems we don't keep a changelog for earlier releases, so now the true archeology begins ;) Only 36 cops wait for their version meta data.

Also, I've updated the documentation generation.

@rubocop-hq/rubocop-core if someone wants to update the instructions in manual/configuration.md and how EnabledByDefault/DisabledByDefault works, feel free to contribute to the PR while I'm tackling the Safe options and digging the latest version meta data

@bquorning

This comment has been minimized.

Copy link
Member

bquorning commented Sep 21, 2018

What does VersionChanged mean? Would it be possible for a cop to be “changed” twice, and can VersionChanged be an array of values?

@Darhazer

This comment has been minimized.

Copy link
Member Author

Darhazer commented Sep 21, 2018

What does VersionChanged mean? Would it be possible for a cop to be “changed” twice, and can VersionChanged be an array of values?

We keep only the latest version in which the cop was changed. VersionChanged means anything that affects configuration, including adding or removing a configuration option and changing default values. Adding or removing auto-correct support also counts, as this allows/disallows using AutoCorrect in the configuration

@bbatsov

This comment has been minimized.

Copy link
Collaborator

bbatsov commented Sep 21, 2018

I processed all cops down to version 0.5 - seems we don't keep a changelog for earlier releases, so now the true archeology begins ;) Only 36 cops ways for their version meta data.

That's fine. We can fill in the missing data later.

@rubocop-hq/rubocop-core if someone wants to update the instructions in manual/configuration.md and how EnabledByDefault/DisabledByDefault works, feel free to contribute to the PR while I'm tackling the Safe options and digging the latest version meta data

For the safe metadata - feel free to just set everything to safe and we can just tweak this later. There are some well-known examples of unsafe cops and unsafe autocorrects and you should certainly mark those, but I don't want you to spend too much time checking each cop. I think it's perfectly fine to set the correct metadata gradually.

@bbatsov

This comment has been minimized.

Copy link
Collaborator

bbatsov commented Sep 23, 2018

Review EnabledByDefault/DisabledByDefault option

Btw, review in what sense? I'm guessing we can leave this more or less the same and add something similar for cops with status "New" down the road.

@bquorning

This comment has been minimized.

Copy link
Member

bquorning commented Sep 23, 2018

How will a developer use these new VersionAdded/VersionChanged/VersionRemoved keys? When adding/changing a cop, I won’t necessarily know in which version it will be released.

@bbatsov

This comment has been minimized.

Copy link
Collaborator

bbatsov commented Sep 23, 2018

@bquorning Well, that's always the next release (optimistically), so I think it's pretty easy to guess. Obviously those are going to adjusted around merge time if needed. I'm not concerned about that at all, as I've been using a very similar scheme on other projects and the getting the version numbers right was never a practical problem.

As for the general usage - see #5978 and the related tickets. That's the biggest milestone on the road to 1.0, together with the extraction of rubocop-performance and rubocop-rails.

@Darhazer Darhazer force-pushed the cops-meta-data branch from 7f4d99f to fdfe946 Sep 26, 2018

@Darhazer Darhazer force-pushed the cops-meta-data branch from fdfe946 to 5ccc645 Sep 26, 2018

@Darhazer Darhazer changed the title WIP: Add version meta data Extend cops meta data Sep 26, 2018

@Darhazer

This comment has been minimized.

Copy link
Member Author

Darhazer commented Sep 26, 2018

I rebased on master, adding 0.59.2 to the VersionChanged meta-data, completed the rest of the TODO points, squashed commits, and separated the automatic generated manual in a separate commit for easier reviewing.

Guess it's ready for review and merge.

@bbatsov bbatsov merged commit 930510b into master Sep 26, 2018

21 of 23 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
ci/circleci: cc-setup Your tests passed on CircleCI!
Details
ci/circleci: cc-upload-coverage Your tests passed on CircleCI!
Details
ci/circleci: documentation-checks Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: jruby-9.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.2-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.2-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.2-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.3-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.4-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-2.5-spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-rc-ascii_spec Your tests passed on CircleCI!
Details
ci/circleci: ruby-rc-rubocop Your tests passed on CircleCI!
Details
ci/circleci: ruby-rc-spec Your tests passed on CircleCI!
Details

@bbatsov bbatsov deleted the cops-meta-data branch Sep 26, 2018

@bbatsov

This comment has been minimized.

Copy link
Collaborator

bbatsov commented Sep 26, 2018

Amazing work! 🙇 ❤️ 💯

Now on to using the metadata for great good! (#5979)

koic added a commit to koic/rubocop that referenced this pull request Oct 6, 2018

Update the development manual and configuration doc
Follow up of rubocop-hq#6293.

config/enabled.yml and config/disabled.yml has been merged into config/default.yml.

@koic koic referenced this pull request Oct 6, 2018

Merged

Update the development manual and configuration doc #6365

5 of 8 tasks complete

bbatsov added a commit that referenced this pull request Oct 8, 2018

Update the development manual and configuration doc
Follow up of #6293.

config/enabled.yml and config/disabled.yml has been merged into config/default.yml.

koic added a commit to koic/rubocop that referenced this pull request Oct 15, 2018

Add `VersionAdded` to config/default.yml when running `rake new_cop`
rubocop-hq#6293 extended cop metadata.

This PR adds `VersionAdded` to config/default.yml when running `rake new_cop`.

The following is an example.

```console
% rubocop -V
0.59.2 (using Parser 2.5.1.2, running on ruby 2.5.1 x86_64-darwin17)
% bunle exec rake new_cop[Lint/TheNewCop]
```

In the current RuboCop, a new cop is added with a minor version.

```diff
diff --git a/config/default.yml b/config/default.yml
index e784ea6b7..522f6aa4e 100644
--- a/config/default.yml
+++ b/config/default.yml
@@ -1507,6 +1507,11 @@ Lint/Syntax:
   VersionAdded: 0.9

+Lint/TheNewCop:
+  Description: 'TODO: Write a description of the cop.'
+  Enabled: true
+  VersionAdded: 0.60
+
 Lint/UnderscorePrefixedVariableName:
   Description: 'Do not use prefix `_` for a variable that is used.'
   Enabled: true
```

bbatsov added a commit that referenced this pull request Oct 15, 2018

Add `VersionAdded` to config/default.yml when running `rake new_cop`
#6293 extended cop metadata.

This PR adds `VersionAdded` to config/default.yml when running `rake new_cop`.

The following is an example.

```console
% rubocop -V
0.59.2 (using Parser 2.5.1.2, running on ruby 2.5.1 x86_64-darwin17)
% bunle exec rake new_cop[Lint/TheNewCop]
```

In the current RuboCop, a new cop is added with a minor version.

```diff
diff --git a/config/default.yml b/config/default.yml
index e784ea6b7..522f6aa4e 100644
--- a/config/default.yml
+++ b/config/default.yml
@@ -1507,6 +1507,11 @@ Lint/Syntax:
   VersionAdded: 0.9

+Lint/TheNewCop:
+  Description: 'TODO: Write a description of the cop.'
+  Enabled: true
+  VersionAdded: 0.60
+
 Lint/UnderscorePrefixedVariableName:
   Description: 'Do not use prefix `_` for a variable that is used.'
   Enabled: true
```

koic added a commit to koic/rubocop that referenced this pull request Oct 27, 2018

Fix missing zero for version metadata
Follow up of rubocop-hq#6293.

Since float lacks 0, This PR replaced it with string.

```console
% ruby -e 'p 0.50'
0.5
```

The following is an updated manual example.

```diff
@@ -918,7 +918,7 @@ EnforcedStyle | `runtime_error` | `runtime_error`,
`standard_error`

 Enabled by default | Safe | Supports autocorrection | VersionAdded |
 VersionChanged
  --- | --- | --- | --- | ---
  -Enabled | Yes | No | 0.5 |
  +Enabled | Yes | No | 0.50 |
```

@koic koic referenced this pull request Oct 27, 2018

Merged

Fix missing zero for version metadata #6414

6 of 8 tasks complete

bbatsov added a commit that referenced this pull request Oct 28, 2018

Fix missing zero for version metadata
Follow up of #6293.

Since float lacks 0, This PR replaced it with string.

```console
% ruby -e 'p 0.50'
0.5
```

The following is an updated manual example.

```diff
@@ -918,7 +918,7 @@ EnforcedStyle | `runtime_error` | `runtime_error`,
`standard_error`

 Enabled by default | Safe | Supports autocorrection | VersionAdded |
 VersionChanged
  --- | --- | --- | --- | ---
  -Enabled | Yes | No | 0.5 |
  +Enabled | Yes | No | 0.50 |
```

@deivid-rodriguez deivid-rodriguez referenced this pull request Nov 4, 2018

Merged

Style/DateTime tweaks #6199

6 of 8 tasks complete

itsWill added a commit to itsWill/rubocop that referenced this pull request Nov 13, 2018

Add `VersionAdded` to config/default.yml when running `rake new_cop`
rubocop-hq#6293 extended cop metadata.

This PR adds `VersionAdded` to config/default.yml when running `rake new_cop`.

The following is an example.

```console
% rubocop -V
0.59.2 (using Parser 2.5.1.2, running on ruby 2.5.1 x86_64-darwin17)
% bunle exec rake new_cop[Lint/TheNewCop]
```

In the current RuboCop, a new cop is added with a minor version.

```diff
diff --git a/config/default.yml b/config/default.yml
index e784ea6b7..522f6aa4e 100644
--- a/config/default.yml
+++ b/config/default.yml
@@ -1507,6 +1507,11 @@ Lint/Syntax:
   VersionAdded: 0.9

+Lint/TheNewCop:
+  Description: 'TODO: Write a description of the cop.'
+  Enabled: true
+  VersionAdded: 0.60
+
 Lint/UnderscorePrefixedVariableName:
   Description: 'Do not use prefix `_` for a variable that is used.'
   Enabled: true
```

itsWill added a commit to itsWill/rubocop that referenced this pull request Nov 13, 2018

Fix missing zero for version metadata
Follow up of rubocop-hq#6293.

Since float lacks 0, This PR replaced it with string.

```console
% ruby -e 'p 0.50'
0.5
```

The following is an updated manual example.

```diff
@@ -918,7 +918,7 @@ EnforcedStyle | `runtime_error` | `runtime_error`,
`standard_error`

 Enabled by default | Safe | Supports autocorrection | VersionAdded |
 VersionChanged
  --- | --- | --- | --- | ---
  -Enabled | Yes | No | 0.5 |
  +Enabled | Yes | No | 0.50 |
```

koic added a commit to koic/rubocop-rails that referenced this pull request Dec 19, 2018

Add rake documentation tasks
## Summary

This PR adds some documentation tasks to rake command.

### Before

```console
% bundle exec rake -T
rake build            # Build rubocop-rails-0.5.0.gem into the pkg
directory
rake clean            # Remove any temporary products
rake clobber          # Remove any generated files
rake coverage         # Run RSpec with code coverage
rake install          # Build and install rubocop-rails-0.5.0.gem into
system gems
rake install:local    # Build and install rubocop-rails-0.5.0.gem into
system gems without network access
rake release[remote]  # Create tag v0.5.0 and build and push
rubocop-rails-0.5.0.gem to rubygems.org
rake spec             # Run RSpec code examples
```

### After

```console
% bundle exec rake -T
rake build                            # Build rubocop-rails-0.5.0.gem
into the pkg directory
rake clean                            # Remove any temporary products
rake clobber                          # Remove any generated files
rake coverage                         # Run RSpec with code coverage
rake documentation_syntax_check       # Syntax check for the
documentation comments
rake generate_cops_documentation      # Generate docs of all cops
departments
rake install                          # Build and install
rubocop-rails-0.5.0.gem into system gems
rake install:local                    # Build and install
rubocop-rails-0.5.0.gem into system gems without network access
rake release[remote]                  # Create tag v0.5.0 and build and
push rubocop-rails-0.5.0.gem to rubygems.org
rake spec                             # Run RSpec code examples
rake yard_for_generate_documentation  # Generate YARD Documentation
```

It is based on the following RuboCop RSpec implementation.
https://github.com/rubocop-hq/rubocop-rspec/blob/v1.30.1/tasks/cops_documentation.rake

## Other Information

In the future `Safe` and `SafeAutoCorrect` metadata will be added in another PR.

Related to rubocop-hq/rubocop#6293 and
rubocop-hq/rubocop-rspec#699.

@koic koic referenced this pull request Dec 19, 2018

Merged

Add rake documentation tasks #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment