rubocop-socketry 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 445a5ee210147c4a5ff2fd64e9b9b652c05d8d367a5e22c6e021ad7ae32c9b0b
4
+ data.tar.gz: 68a660ee1a45d210fd1aff0a1fd95b6111231e6e94b8d415fa480d7e804756a0
5
+ SHA512:
6
+ metadata.gz: 8c3386766d825b8fa057c71f8dc58ee484378f0ec47a3a6445705f0a7d6e03ea54c0595ad946a445651a6a7952a49c8b23d258465f047415c13a98558617bf63
7
+ data.tar.gz: 4e20dfca038f92fd398fcf3d1dbf64fbab9d639de3c9dc86b41080f1dd231531fe5786338836c6a486544e745c1c7d8f90374a28db8996792e53c5ed3b80b034
checksums.yaml.gz.sig ADDED
Binary file
data/agent.md ADDED
@@ -0,0 +1,47 @@
1
+ # Agent
2
+
3
+ ## Context
4
+
5
+ This section provides links to documentation from installed packages. It is automatically generated and may be updated by running `bake agent:context:install`.
6
+
7
+ **Important:** Before performing any code, documentation, or analysis tasks, always read and apply the full content of any relevant documentation referenced in the following sections. These context files contain authoritative standards and best practices for documentation, code style, and project-specific workflows. **Do not proceed with any actions until you have read and incorporated the guidance from relevant context files.**
8
+
9
+ ### agent-context
10
+
11
+ Install and manage context files from Ruby gems.
12
+
13
+ #### [Usage Guide](.context/agent-context/usage.md)
14
+
15
+ `agent-context` is a tool that helps you discover and install contextual information from Ruby gems for AI agents. Gems can provide additional documentation, examples, and guidance in a `context/` ...
16
+
17
+ ### decode
18
+
19
+ Code analysis for documentation generation.
20
+
21
+ #### [Getting Started with Decode](.context/decode/getting-started.md)
22
+
23
+ The Decode gem provides programmatic access to Ruby code structure and metadata. It can parse Ruby files and extract definitions, comments, and documentation pragmas, enabling code analysis, docume...
24
+
25
+ #### [Documentation Coverage](.context/decode/coverage.md)
26
+
27
+ This guide explains how to test and monitor documentation coverage in your Ruby projects using the Decode gem's built-in bake tasks.
28
+
29
+ #### [Ruby Documentation](.context/decode/ruby-documentation.md)
30
+
31
+ This guide covers documentation practices and pragmas supported by the Decode gem for documenting Ruby code. These pragmas provide structured documentation that can be parsed and used to generate A...
32
+
33
+ ### sus
34
+
35
+ A fast and scalable test runner.
36
+
37
+ #### [Using Sus Testing Framework](.context/sus/usage.md)
38
+
39
+ Sus is a modern Ruby testing framework that provides a clean, BDD-style syntax for writing tests. It's designed to be fast, simple, and expressive.
40
+
41
+ #### [Mocking](.context/sus/mocking.md)
42
+
43
+ There are two types of mocking in sus: `receive` and `mock`. The `receive` matcher is a subset of full mocking and is used to set expectations on method calls, while `mock` can be used to replace m...
44
+
45
+ #### [Shared Test Behaviors and Fixtures](.context/sus/shared.md)
46
+
47
+ Sus provides shared test contexts which can be used to define common behaviours or tests that can be reused across one or more test files.
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "rubocop"
7
+
8
+ module RuboCop
9
+ module Socketry
10
+ module Layout
11
+ # A RuboCop cop that enforces consistent blank line indentation based on AST structure.
12
+ # This cop ensures that blank lines are indented correctly according to their context in the code,
13
+ # using a two-pass algorithm that analyzes the AST to determine proper indentation levels.
14
+ class ConsistentBlankLineIndentation < RuboCop::Cop::Base
15
+ extend Cop::AutoCorrector
16
+ include Cop::Alignment
17
+ include Cop::RangeHelp
18
+
19
+ # @attribute [String] The message displayed when a blank line has incorrect indentation.
20
+ MESSAGE = "Blank lines must have the correct indentation."
21
+
22
+ # Get the configured indentation width from cop configuration or fallback to default.
23
+ # @returns [Integer] The number of spaces or tabs to use for each indentation level.
24
+ def configured_indentation_width
25
+ cop_config["IndentationWidth"] || config.for_cop("Layout/IndentationWidth")["Width"] || 1
26
+ end
27
+
28
+ # Get the configured indentation style from cop configuration or fallback to default.
29
+ # @returns [String] The indentation style, either "tab" or "space".
30
+ def configured_indentation_style
31
+ cop_config["IndentationStyle"] || config.for_cop("Layout/IndentationStyle")["Style"] || "tab"
32
+ end
33
+
34
+ # Generate indentation string based on the current level and configured style.
35
+ # @parameter width [Integer] The number of indentation levels to apply.
36
+ # @returns [String] The indentation string (tabs or spaces).
37
+ def indentation(width)
38
+ case configured_indentation_style
39
+ when "tab"
40
+ "\t" * (width * configured_indentation_width)
41
+ when "space"
42
+ " " * (width * configured_indentation_width)
43
+ end
44
+ end
45
+
46
+ # Main investigation method that processes the source code and checks blank line indentation.
47
+ # This method implements a two-pass algorithm: first building indentation deltas from the AST,
48
+ # then processing each line to check blank lines against expected indentation.
49
+ def on_new_investigation
50
+ indentation_deltas = build_indentation_deltas
51
+ current_level = 0
52
+
53
+ processed_source.lines.each_with_index do |line, index|
54
+ line_number = index + 1
55
+
56
+ # Check blank lines for correct indentation:
57
+ if line.strip.empty?
58
+ expected_indentation = indentation(current_level)
59
+ if line != expected_indentation
60
+ add_offense(
61
+ source_range(processed_source.buffer, line_number, 0, line.length),
62
+ message: MESSAGE
63
+ ) do |corrector|
64
+ corrector.replace(
65
+ source_range(processed_source.buffer, line_number, 0, line.length),
66
+ expected_indentation
67
+ )
68
+ end
69
+ end
70
+ end
71
+
72
+ # Apply indentation delta for this line:
73
+ delta = indentation_deltas[line_number] || 0
74
+ current_level += delta
75
+ end
76
+ end
77
+
78
+ private
79
+
80
+ # Build a hash mapping line numbers to indentation deltas (+1 for indent, -1 for dedent).
81
+ # This method walks the AST to identify where indentation should increase or decrease.
82
+ # @returns [Hash(Integer, Integer)] A hash where keys are line numbers and values are deltas.
83
+ def build_indentation_deltas
84
+ deltas = Hash.new(0)
85
+ walk_ast_for_indentation(processed_source.ast, deltas)
86
+ deltas
87
+ end
88
+
89
+ # Recursively walk the AST to build indentation deltas for block structures.
90
+ # This method identifies nodes that should affect indentation and records the deltas.
91
+ # @parameter node [Parser::AST::Node] The current AST node to process.
92
+ # @parameter deltas [Hash(Integer, Integer)] The deltas hash to populate.
93
+ def walk_ast_for_indentation(node, deltas)
94
+ return unless node.is_a?(Parser::AST::Node)
95
+
96
+ case node.type
97
+ when :block, :hash, :array, :class, :module, :sclass, :def, :defs, :if, :case, :while, :until, :for, :kwbegin
98
+ if location = node.location
99
+ deltas[location.line] += 1
100
+ deltas[location.last_line] -= 1
101
+ end
102
+ end
103
+
104
+ node.children.each do |child|
105
+ walk_ast_for_indentation(child, deltas)
106
+ end
107
+ end
108
+
109
+ # Create a source range for a specific line and column position.
110
+ # @parameter buffer [Parser::Source::Buffer] The source buffer.
111
+ # @parameter line [Integer] The line number (1-indexed).
112
+ # @parameter column [Integer] The column position.
113
+ # @parameter length [Integer] The length of the range.
114
+ # @returns [Parser::Source::Range] The source range object.
115
+ def source_range(buffer, line, column, length)
116
+ Parser::Source::Range.new(buffer, buffer.line_range(line).begin_pos + column, buffer.line_range(line).begin_pos + column + length)
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require "lint_roller"
7
+ require_relative "version"
8
+
9
+ module RuboCop
10
+ module Socketry
11
+ # Represents a LintRoller plugin that provides RuboCop rules for Socketry projects.
12
+ # This plugin integrates custom RuboCop cops and configuration into the LintRoller system.
13
+ class Plugin < LintRoller::Plugin
14
+ # Initialize the plugin with version information.
15
+ def initialize(...)
16
+ super
17
+ @version = RuboCop::Socketry::VERSION
18
+ end
19
+
20
+ # Get information about this plugin for the LintRoller system.
21
+ # @returns [LintRoller::About] Plugin metadata including name, version, and description.
22
+ def about
23
+ LintRoller::About.new(
24
+ name: "rubocop-socketry",
25
+ version: @version,
26
+ homepage: "https://github.com/socketry/rubocop-socketry",
27
+ description: "RuboCop rules for Socketry projects."
28
+ )
29
+ end
30
+
31
+ # Define the rules configuration for this plugin.
32
+ # @parameter context [Object] The LintRoller context object.
33
+ # @returns [LintRoller::Rules] Rules configuration specifying the path to the default RuboCop config.
34
+ def rules(context)
35
+ LintRoller::Rules.new(
36
+ type: :path,
37
+ config_format: :rubocop,
38
+ value: Pathname.new(__dir__).join("../../../config/default.yml")
39
+ )
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ module RuboCop
7
+ module Socketry
8
+ VERSION = "0.1.0"
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2025, by Samuel Williams.
5
+
6
+ require_relative "socketry/version"
7
+ require_relative "socketry/plugin"
8
+ require_relative "socketry/layout/consistent_blank_line_indentation"
9
+
10
+ # @namespace
11
+ module RuboCop
12
+ # @namespace
13
+ module Socketry
14
+ # @namespace
15
+ module Layout
16
+ end
17
+ end
18
+ end
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2025, by Samuel Williams.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,50 @@
1
+ # RuboCop::Socketry
2
+
3
+ RuboCop rules for Socketry projects.
4
+
5
+ [![Development Status](https://github.com/socketry/rubocop-socketry/workflows/Test/badge.svg)](https://github.com/socketry/rubocop-socketry/actions?workflow=Test)
6
+
7
+ ## Installation
8
+
9
+ bundle add rubocop-socketry
10
+
11
+ ## Usage
12
+
13
+ Please see the [project documentation](https://socketry.github.io/rubocop-socketry/) for more details.
14
+
15
+ ## Available Cops
16
+
17
+ ### Layout/ConsistentBlankLineIndentation
18
+
19
+ Ensures that blank lines have the same indentation as the previous non-blank line.
20
+
21
+ ``` yaml
22
+ Layout/ConsistentBlankLineIndentation:
23
+ Enabled: true
24
+ ```
25
+
26
+ ## Releases
27
+
28
+ Please see the [project releases](https://socketry.github.io/rubocop-socketry/releases/index) for all releases.
29
+
30
+ ### v0.1.0
31
+
32
+ - Initial implementaiton of `Layout/ConsistentBlankLineIndentation`.
33
+
34
+ ## Contributing
35
+
36
+ We welcome contributions to this project.
37
+
38
+ 1. Fork it.
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
40
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
41
+ 4. Push to the branch (`git push origin my-new-feature`).
42
+ 5. Create new Pull Request.
43
+
44
+ ### Developer Certificate of Origin
45
+
46
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
47
+
48
+ ### Community Guidelines
49
+
50
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
data/releases.md ADDED
@@ -0,0 +1,5 @@
1
+ # Releases
2
+
3
+ ## v0.1.0
4
+
5
+ - Initial implementaiton of `Layout/ConsistentBlankLineIndentation`.
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-socketry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ bindir: bin
9
+ cert_chain:
10
+ - |
11
+ -----BEGIN CERTIFICATE-----
12
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
13
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
14
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
15
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
16
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
17
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
18
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
19
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
20
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
21
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
22
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
23
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
24
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
25
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
26
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
27
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
28
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
29
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
30
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
31
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
32
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
33
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
34
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
35
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
36
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
37
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
38
+ -----END CERTIFICATE-----
39
+ date: 1980-01-02 00:00:00.000000000 Z
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: lint_roller
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '1.72'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '1.72'
69
+ executables: []
70
+ extensions: []
71
+ extra_rdoc_files: []
72
+ files:
73
+ - agent.md
74
+ - lib/rubocop/socketry.rb
75
+ - lib/rubocop/socketry/layout/consistent_blank_line_indentation.rb
76
+ - lib/rubocop/socketry/plugin.rb
77
+ - lib/rubocop/socketry/version.rb
78
+ - license.md
79
+ - readme.md
80
+ - releases.md
81
+ homepage: https://github.com/socketry/rubocop-socketry
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ default_lint_roller_plugin: RuboCop::Socketry::Plugin
86
+ documentation_uri: https://socketry.github.io/rubocop-socketry/
87
+ funding_uri: https://github.com/sponsors/ioquatix/
88
+ source_code_uri: https://github.com/socketry/rubocop-socketry.git
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '3.2'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.6.7
104
+ specification_version: 4
105
+ summary: RuboCop rules for Socketry projects
106
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ m˴���;�#�<�4z��su�(�G9����K@�.bXM�T��g�/��J���y�l�4!�o�{J���{�����PC�wx��_c�Q(���ƭ���9Я�K�ދ��n1�4��#q���L��a��o����פkߛ_2�'vh���?��m!�u���+,��fqCۿ-�7��?�8�� ����2r�� .K��d��|%#�Kd�C���U<��$S��o� fDO�(��{�F�c��s��c���BM�Z>y7!�󠊸b�
2
+ %"B�T����F6��/�&&��0���_�8��L~���r^{�+F�K�<3#��K
3
+ ��˲1�0�L|X��t�qW��zB��Ņ�L��Nt"
4
+ �Q