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

Use attr_writer when validations are not needed #320

Open
tagliala opened this issue Nov 23, 2023 · 3 comments
Open

Use attr_writer when validations are not needed #320

tagliala opened this issue Nov 23, 2023 · 3 comments
Labels
stale Will be closed soon if there are no updates.

Comments

@tagliala
Copy link
Contributor

tagliala commented Nov 23, 2023

Offences found by fasterer

lib/axlsx/drawing/area_series.rb:49 Use attr_writer for writing to ivars.

lib/axlsx/drawing/axis.rb:89 Use attr_writer for writing to ivars.

lib/axlsx/drawing/bar_series.rb:48 Use attr_writer for writing to ivars.

lib/axlsx/drawing/bubble_series.rb:37 Use attr_writer for writing to ivars.

lib/axlsx/drawing/line_series.rb:49 Use attr_writer for writing to ivars.

lib/axlsx/drawing/scatter_series.rb:59 Use attr_writer for writing to ivars.
lib/axlsx/drawing/scatter_series.rb:70 Use attr_writer for writing to ivars.

lib/axlsx/workbook/worksheet/conditional_formatting.rb:64 Use attr_writer for writing to ivars.

lib/axlsx/workbook/worksheet/rich_text_run.rb:21 Use attr_writer for writing to ivars.

lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb:36 Use attr_writer for writing to ivars.

def color=(v)
@color = v
end

def color=(color_rgb)
@color = color_rgb
end

def series_color=(v)
@series_color = v
end

def color=(v)
@color = v
end

def color=(v)
@color = v
end

def color=(v)
@color = v
end

def ln_width=(v)
@ln_width = v
end

def value=(value)
@value = value
end

def target=(target)
@target = target
end

There are several options here:

  1. For uniformity, setting those variables should keep using method=
  2. For performance and code quality, those variables should use attr_writer
  3. Some validations are missing

Comparison (IPS 2.6.10):
         attr_writer: 16354506.9 i/s
              method: 14390115.2 i/s - 1.14x  (± 0.00) slower

Comparison (IPS 3.2.2):
         attr_writer: 16205198.6 i/s
              method: 14282149.6 i/s - 1.13x  (± 0.00) slower
Copy link

This issue has been automatically marked as stale because it has not been commented on for at least three months.
If you have any new information or updates please reply in order to keep the issue open.

@github-actions github-actions bot added the stale Will be closed soon if there are no updates. label Feb 23, 2024
@tagliala
Copy link
Contributor Author

keep open

@github-actions github-actions bot removed the stale Will be closed soon if there are no updates. label Feb 24, 2024
Copy link

This issue has been automatically marked as stale because it has not been commented on for at least three months.
If you have any new information or updates please reply in order to keep the issue open.

@github-actions github-actions bot added the stale Will be closed soon if there are no updates. label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Will be closed soon if there are no updates.
Projects
None yet
Development

No branches or pull requests

1 participant