-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add clippy check to travis #986
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I'd like to land this and run clippy regularly, but not have travis break the build if clippy fails. We would still want it to be obvious on the status that clippy failed, though.
I think one way we could work this is to have travis open a second status issue like "clippy" for each commit it builds and post the clippy status separately from tests. I've asked #travis people about this before, and apparently there's no built-in support for it. We would have to wrap GitHub API ourselves.
Left some comments about changes before I would land.
src/ansi.rs
Outdated
buf.push_str(&format!("{:?},", *item as char)); | ||
} | ||
buf.push_str("],"); | ||
#[inline] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need inline here. I honestly can't remember why this was ever a macro...
src/logging.rs
Outdated
@@ -28,6 +28,7 @@ pub struct Logger<T> { | |||
} | |||
|
|||
impl<T: Send + io::Write> Logger<T> { | |||
#[cfg_attr(feature = "clippy", allow(new_ret_no_self))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment here pointing to the issue tracking this broken lint: rust-lang/rust-clippy#734
src/renderer/mod.rs
Outdated
@@ -1125,7 +1125,7 @@ impl ShaderProgram { | |||
gl::GetShaderiv(shader, gl::COMPILE_STATUS, &mut success); | |||
} | |||
|
|||
if success == (gl::TRUE as GLint) { | |||
if success == i32::from(gl::TRUE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be GLint::from
rather than i32::from
.
src/selection.rs
Outdated
@@ -136,25 +136,22 @@ impl Selection { | |||
Selection::Simple { ref mut region } => { | |||
region.end = Anchor::new(location, side); | |||
}, | |||
Selection::Semantic { ref mut region, .. } => { | |||
Selection::Semantic { ref mut region, .. } | Selection::Lines { ref mut region, .. } => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Break line after pipe
.travis.yml
Outdated
|
||
script: | ||
- cargo test --no-default-features | ||
- ./build.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try and keep all the shell commands in the script
section rather than adding build.sh
. The build.sh script can be
- if [[ $VERSION == "nightly" ]]; then cargo test --no-default-features --features "clippy"; fi
- if [[ $VERSION != "nightly" ]]; then cargo test --no-default-features; fi
src/ansi.rs
Outdated
@@ -360,6 +360,9 @@ pub enum CursorStyle { | |||
|
|||
/// Cursor is a vertical bar `⎸` | |||
Beam, | |||
|
|||
/// Cursor is a box like `☐` | |||
Box, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks new in this PR. Can you pull it out into a separate patch? Small nit also -- it would be nice to name this Hollow
or Rect
or something other than Box
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe HollowBlock
would be best
@@ -988,6 +990,11 @@ impl Term { | |||
) -> RenderableCellsIter { | |||
let selection = selection.and_then(|s| s.to_span(self)) | |||
.map(|span| span.to_range()); | |||
let cursor = if window_focused { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes were made to reduce the amount of parameters of the method below clippy's threshold.
src/tty.rs
Outdated
@@ -70,8 +70,8 @@ fn openpty(rows: u8, cols: u8) -> (c_int, c_int) { | |||
let mut slave: c_int = 0; | |||
|
|||
let win = winsize { | |||
ws_row: rows as libc::c_ushort, | |||
ws_col: cols as libc::c_ushort, | |||
ws_row: u16::from(rows), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c_ushort::from
src/tty.rs
Outdated
@@ -93,8 +93,8 @@ fn openpty(rows: u8, cols: u8) -> (c_int, c_int) { | |||
let mut slave: c_int = 0; | |||
|
|||
let mut win = winsize { | |||
ws_row: rows as libc::c_ushort, | |||
ws_col: cols as libc::c_ushort, | |||
ws_row: u16::from(rows), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c_ushort::from
src/tty.rs
Outdated
@@ -113,6 +113,7 @@ fn openpty(rows: u8, cols: u8) -> (c_int, c_int) { | |||
/// Really only needed on BSD, but should be fine elsewhere | |||
fn set_controlling_terminal(fd: c_int) { | |||
let res = unsafe { | |||
#[allow(clippy)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What didn't clippy like about this? It would be nice to just disable a single lint rather than all of clippy for this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a problem with multiple platforms. Because TIOSCTTY
has a different type on macos and linux. So the conversion fails on clippy because it's either an unnecessary conversion, or an incorrect type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to use if cfg!(target_os = "macos")
but I wasn't able to make it work. Clippy still complained about the branch that shouldn't be reached on linux.
Rebased this on top of master, should be good now when travis doesn't complain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the CursorStyle::Box
naming and then ship this
src/ansi.rs
Outdated
@@ -360,6 +360,9 @@ pub enum CursorStyle { | |||
|
|||
/// Cursor is a vertical bar `⎸` | |||
Beam, | |||
|
|||
/// Cursor is a box like `☐` | |||
Box, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe HollowBlock
would be best
@@ -113,7 +113,10 @@ fn openpty(rows: u8, cols: u8) -> (c_int, c_int) { | |||
/// Really only needed on BSD, but should be fine elsewhere | |||
fn set_controlling_terminal(fd: c_int) { | |||
let res = unsafe { | |||
libc::ioctl(fd, TIOCSCTTY as _, 0) | |||
// Cross platform issue because on linux this is u64 as u64 (does nothing) | |||
// But on macos this is u32 as u64, asking for u64::from(u32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment!
This commit adds clippy as a required step of the build process. To make this possible, all existing clippy issues have been resolved. I think making clippy part of the travis CI run would be a great step, but if this is not desired, I can also take that part out of this and add just the fixes for all current clippy issues.
Fix all new issues introduced with the latest master.
There were some macos-specific warnings that have been fixed. The travis configuration also has been altered in an attempt to make clippy run only for nightly builds.
Added a custom build matrix so when `VERSION="nightly"` the nightly compiler is used and when `VERSION="stable"` the stable compiler is used.
Fixed a few small issues, reworked the travis configuration and added comments to the allow(_) parts.
Now it should properly make all nightly builds optional.
Changed from `c_ushort` to `libc::c_ushort`.
Rebased branch on top of master and fixed all new clippy warnings.
This commit adds clippy as a required step of the build process. To make
this possible, all existing clippy issues have been resolved.
I think making clippy part of the travis CI run would be a great step,
but if this is not desired, I can also take that part out of this and
add just the fixes for all current clippy issues.